[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/storage/ -> DifferentialDraft.php (source)

   1  <?php
   2  
   3  final class DifferentialDraft extends DifferentialDAO {
   4  
   5    protected $objectPHID;
   6    protected $authorPHID;
   7    protected $draftKey;
   8  
   9    public function getConfiguration() {
  10      return array(
  11        self::CONFIG_COLUMN_SCHEMA => array(
  12          'draftKey' => 'text64',
  13        ),
  14        self::CONFIG_KEY_SCHEMA => array(
  15          'key_unique' => array(
  16            'columns' => array('objectPHID', 'authorPHID', 'draftKey'),
  17            'unique' => true,
  18          ),
  19        ),
  20      )  + parent::getConfiguration();
  21    }
  22  
  23    public static function markHasDraft(
  24      $author_phid,
  25      $object_phid,
  26      $draft_key) {
  27      try {
  28        id(new DifferentialDraft())
  29          ->setObjectPHID($object_phid)
  30          ->setAuthorPHID($author_phid)
  31          ->setDraftKey($draft_key)
  32          ->save();
  33      } catch (AphrontDuplicateKeyQueryException $ex) {
  34        // no worries
  35      }
  36    }
  37  
  38    public static function deleteHasDraft(
  39      $author_phid,
  40      $object_phid,
  41      $draft_key) {
  42      $draft = id(new DifferentialDraft())->loadOneWhere(
  43        'objectPHID = %s AND authorPHID = %s AND draftKey = %s',
  44        $object_phid,
  45        $author_phid,
  46        $draft_key);
  47      if ($draft) {
  48        $draft->delete();
  49      }
  50    }
  51  
  52    public static function deleteAllDrafts(
  53      $author_phid,
  54      $object_phid) {
  55  
  56      $drafts = id(new DifferentialDraft())->loadAllWhere(
  57        'objectPHID = %s AND authorPHID = %s',
  58        $object_phid,
  59        $author_phid);
  60      foreach ($drafts as $draft) {
  61        $draft->delete();
  62      }
  63    }
  64  
  65  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1