[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PhabricatorRepositoryArcanistProject
   4    extends PhabricatorRepositoryDAO
   5    implements
   6      PhabricatorPolicyInterface,
   7      PhabricatorDestructibleInterface {
   8  
   9    protected $name;
  10    protected $repositoryID;
  11  
  12    protected $symbolIndexLanguages = array();
  13    protected $symbolIndexProjects  = array();
  14  
  15    private $repository = self::ATTACHABLE;
  16  
  17    public function getConfiguration() {
  18      return array(
  19        self::CONFIG_AUX_PHID   => true,
  20        self::CONFIG_TIMESTAMPS => false,
  21        self::CONFIG_SERIALIZATION => array(
  22          'symbolIndexLanguages' => self::SERIALIZATION_JSON,
  23          'symbolIndexProjects'  => self::SERIALIZATION_JSON,
  24        ),
  25        self::CONFIG_COLUMN_SCHEMA => array(
  26          'name' => 'text128',
  27          'repositoryID' => 'id?',
  28        ),
  29        self::CONFIG_KEY_SCHEMA => array(
  30          'key_phid' => null,
  31          'phid' => array(
  32            'columns' => array('phid'),
  33            'unique' => true,
  34          ),
  35          'name' => array(
  36            'columns' => array('name'),
  37            'unique' => true,
  38          ),
  39        ),
  40      ) + parent::getConfiguration();
  41    }
  42  
  43    public function generatePHID() {
  44      return PhabricatorPHID::generateNewPHID(
  45        PhabricatorRepositoryArcanistProjectPHIDType::TYPECONST);
  46    }
  47  
  48    // TODO: Remove. Also, T603.
  49    public function loadRepository() {
  50      if (!$this->getRepositoryID()) {
  51        return null;
  52      }
  53      return id(new PhabricatorRepository())->load($this->getRepositoryID());
  54    }
  55  
  56    public function delete() {
  57      $this->openTransaction();
  58  
  59        queryfx(
  60          $this->establishConnection('w'),
  61          'DELETE FROM %T WHERE arcanistProjectID = %d',
  62          id(new PhabricatorRepositorySymbol())->getTableName(),
  63          $this->getID());
  64  
  65        $result = parent::delete();
  66      $this->saveTransaction();
  67      return $result;
  68    }
  69  
  70    public function getRepository() {
  71      return $this->assertAttached($this->repository);
  72    }
  73  
  74    public function attachRepository(PhabricatorRepository $repository = null) {
  75      $this->repository = $repository;
  76      return $this;
  77    }
  78  
  79  
  80  
  81  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  82  
  83    public function getCapabilities() {
  84      return array(
  85        PhabricatorPolicyCapability::CAN_VIEW,
  86        PhabricatorPolicyCapability::CAN_EDIT,
  87      );
  88    }
  89  
  90    public function getPolicy($capability) {
  91      switch ($capability) {
  92        case PhabricatorPolicyCapability::CAN_VIEW:
  93          return PhabricatorPolicies::POLICY_USER;
  94        case PhabricatorPolicyCapability::CAN_EDIT:
  95          return PhabricatorPolicies::POLICY_ADMIN;
  96      }
  97    }
  98  
  99    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
 100      return false;
 101    }
 102  
 103    public function describeAutomaticCapability($capability) {
 104      return null;
 105    }
 106  
 107  
 108  /* -(  PhabricatorDestructibleInterface  )----------------------------------- */
 109  
 110    public function destroyObjectPermanently(
 111      PhabricatorDestructionEngine $engine) {
 112  
 113      $this->openTransaction();
 114      $this->delete();
 115      $this->saveTransaction();
 116    }
 117  
 118  }


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