[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/repository/storage/ -> PhabricatorRepositoryRefCursor.php (source)

   1  <?php
   2  
   3  /**
   4   * Stores the previous value of a ref (like a branch or tag) so we can figure
   5   * out how a repository has changed when we discover new commits or branch
   6   * heads.
   7   */
   8  final class PhabricatorRepositoryRefCursor extends PhabricatorRepositoryDAO
   9    implements PhabricatorPolicyInterface {
  10  
  11    const TYPE_BRANCH = 'branch';
  12    const TYPE_TAG = 'tag';
  13    const TYPE_BOOKMARK = 'bookmark';
  14  
  15    protected $repositoryPHID;
  16    protected $refType;
  17    protected $refNameHash;
  18    protected $refNameRaw;
  19    protected $refNameEncoding;
  20    protected $commitIdentifier;
  21  
  22    private $repository = self::ATTACHABLE;
  23  
  24    public function getConfiguration() {
  25      return array(
  26        self::CONFIG_TIMESTAMPS => false,
  27        self::CONFIG_BINARY => array(
  28          'refNameRaw' => true,
  29        ),
  30        self::CONFIG_COLUMN_SCHEMA => array(
  31          'refType' => 'text32',
  32          'refNameHash' => 'bytes12',
  33          'commitIdentifier' => 'text40',
  34  
  35          // T6203/NULLABILITY
  36          // This probably should not be nullable; refNameRaw is not nullable.
  37          'refNameEncoding' => 'text16?',
  38        ),
  39        self::CONFIG_KEY_SCHEMA => array(
  40          'key_cursor' => array(
  41            'columns' => array('repositoryPHID', 'refType', 'refNameHash'),
  42          ),
  43        ),
  44      ) + parent::getConfiguration();
  45    }
  46  
  47    public function getRefName() {
  48      return $this->getUTF8StringFromStorage(
  49        $this->getRefNameRaw(),
  50        $this->getRefNameEncoding());
  51    }
  52  
  53    public function setRefName($ref_raw) {
  54      $this->setRefNameRaw($ref_raw);
  55      $this->setRefNameHash(PhabricatorHash::digestForIndex($ref_raw));
  56      $this->setRefNameEncoding($this->detectEncodingForStorage($ref_raw));
  57  
  58      return $this;
  59    }
  60  
  61    public function attachRepository(PhabricatorRepository $repository) {
  62      $this->repository = $repository;
  63      return $this;
  64    }
  65  
  66    public function getRepository() {
  67      return $this->assertAttached($this->repository);
  68    }
  69  
  70  
  71  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  72  
  73  
  74    public function getCapabilities() {
  75      return array(
  76        PhabricatorPolicyCapability::CAN_VIEW,
  77      );
  78    }
  79  
  80    public function getPolicy($capability) {
  81      return $this->getRepository()->getPolicy($capability);
  82    }
  83  
  84    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
  85      return $this->getRepository()->hasAutomaticCapability($capability, $viewer);
  86    }
  87  
  88    public function describeAutomaticCapability($capability) {
  89      return pht('Repository refs have the same policies as their repository.');
  90    }
  91  
  92  }


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