[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/releeph/storage/ -> ReleephProject.php (source)

   1  <?php
   2  
   3  final class ReleephProject extends ReleephDAO
   4    implements PhabricatorPolicyInterface {
   5  
   6    const DEFAULT_BRANCH_NAMESPACE = 'releeph-releases';
   7    const SYSTEM_AGENT_USERNAME_PREFIX = 'releeph-agent-';
   8  
   9    protected $name;
  10  
  11    // Specifying the place to pick from is a requirement for svn, though not
  12    // for git. It's always useful though for reasoning about what revs have
  13    // been picked and which haven't.
  14    protected $trunkBranch;
  15  
  16    protected $repositoryPHID;
  17    protected $isActive;
  18    protected $createdByUserPHID;
  19    protected $arcanistProjectID;
  20  
  21    protected $details = array();
  22  
  23    private $repository = self::ATTACHABLE;
  24    private $arcanistProject = self::ATTACHABLE;
  25  
  26    public function getConfiguration() {
  27      return array(
  28        self::CONFIG_AUX_PHID => true,
  29        self::CONFIG_SERIALIZATION => array(
  30          'details' => self::SERIALIZATION_JSON,
  31        ),
  32        self::CONFIG_COLUMN_SCHEMA => array(
  33          'name' => 'text128',
  34          'trunkBranch' => 'text255',
  35          'isActive' => 'bool',
  36        ),
  37        self::CONFIG_KEY_SCHEMA => array(
  38          'projectName' => array(
  39            'columns' => array('name'),
  40            'unique' => true,
  41          ),
  42        ),
  43      ) + parent::getConfiguration();
  44    }
  45  
  46    public function generatePHID() {
  47      return PhabricatorPHID::generateNewPHID(ReleephProductPHIDType::TYPECONST);
  48    }
  49  
  50    public function getDetail($key, $default = null) {
  51      return idx($this->details, $key, $default);
  52    }
  53  
  54    public function getURI($path = null) {
  55      $components = array(
  56        '/releeph/product',
  57        $this->getID(),
  58        $path,
  59      );
  60      return implode('/', $components);
  61    }
  62  
  63    public function setDetail($key, $value) {
  64      $this->details[$key] = $value;
  65      return $this;
  66    }
  67  
  68    public function getArcanistProject() {
  69      return $this->assertAttached($this->arcanistProject);
  70    }
  71  
  72    public function attachArcanistProject(
  73      PhabricatorRepositoryArcanistProject $arcanist_project = null) {
  74      $this->arcanistProject = $arcanist_project;
  75      return $this;
  76    }
  77  
  78    public function getPushers() {
  79      return $this->getDetail('pushers', array());
  80    }
  81  
  82    public function isPusher(PhabricatorUser $user) {
  83      // TODO Deprecate this once `isPusher` is out of the Facebook codebase.
  84      return $this->isAuthoritative($user);
  85    }
  86  
  87    public function isAuthoritative(PhabricatorUser $user) {
  88      return $this->isAuthoritativePHID($user->getPHID());
  89    }
  90  
  91    public function isAuthoritativePHID($phid) {
  92      $pushers = $this->getPushers();
  93      if (!$pushers) {
  94        return true;
  95      } else {
  96        return in_array($phid, $pushers);
  97      }
  98    }
  99  
 100    public function attachRepository(PhabricatorRepository $repository) {
 101      $this->repository = $repository;
 102      return $this;
 103    }
 104  
 105    public function getRepository() {
 106      return $this->assertAttached($this->repository);
 107    }
 108  
 109    public function getReleephFieldSelector() {
 110      return new ReleephDefaultFieldSelector();
 111    }
 112  
 113    public function isTestFile($filename) {
 114      $test_paths = $this->getDetail('testPaths', array());
 115  
 116      foreach ($test_paths as $test_path) {
 117        if (preg_match($test_path, $filename)) {
 118          return true;
 119        }
 120      }
 121      return false;
 122    }
 123  
 124  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
 125  
 126    public function getCapabilities() {
 127      return array(
 128        PhabricatorPolicyCapability::CAN_VIEW,
 129        PhabricatorPolicyCapability::CAN_EDIT,
 130      );
 131    }
 132  
 133    public function getPolicy($capability) {
 134      return PhabricatorPolicies::POLICY_USER;
 135    }
 136  
 137    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
 138      return false;
 139    }
 140  
 141    public function describeAutomaticCapability($capability) {
 142      return null;
 143    }
 144  
 145  
 146  }


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