[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/doorkeeper/storage/ -> DoorkeeperExternalObject.php (source)

   1  <?php
   2  
   3  final class DoorkeeperExternalObject extends DoorkeeperDAO
   4    implements PhabricatorPolicyInterface {
   5  
   6    protected $objectKey;
   7    protected $applicationType;
   8    protected $applicationDomain;
   9    protected $objectType;
  10    protected $objectID;
  11    protected $objectURI;
  12    protected $importerPHID;
  13    protected $properties = array();
  14    protected $viewPolicy;
  15  
  16    public function getConfiguration() {
  17      return array(
  18        self::CONFIG_AUX_PHID => true,
  19        self::CONFIG_SERIALIZATION => array(
  20          'properties' => self::SERIALIZATION_JSON,
  21        ),
  22        self::CONFIG_COLUMN_SCHEMA => array(
  23          'objectKey' => 'bytes12',
  24          'applicationType' => 'text32',
  25          'applicationDomain' => 'text32',
  26          'objectType' => 'text32',
  27          'objectID' => 'text64',
  28          'objectURI' => 'text128?',
  29          'importerPHID' => 'phid?',
  30        ),
  31        self::CONFIG_KEY_SCHEMA => array(
  32          'key_object' => array(
  33            'columns' => array('objectKey'),
  34            'unique' => true,
  35          ),
  36          'key_full' => array(
  37            'columns' => array(
  38              'applicationType',
  39              'applicationDomain',
  40              'objectType',
  41              'objectID',
  42            ),
  43          ),
  44        ),
  45      ) + parent::getConfiguration();
  46    }
  47  
  48    public function generatePHID() {
  49      return PhabricatorPHID::generateNewPHID(
  50        PhabricatorPHIDConstants::PHID_TYPE_XOBJ);
  51    }
  52  
  53    public function getProperty($key, $default = null) {
  54      return idx($this->properties, $key, $default);
  55    }
  56  
  57    public function setProperty($key, $value) {
  58      $this->properties[$key] = $value;
  59      return $this;
  60    }
  61  
  62    public function getObjectKey() {
  63      $key = parent::getObjectKey();
  64      if ($key === null) {
  65        $key = $this->getRef()->getObjectKey();
  66      }
  67      return $key;
  68    }
  69  
  70    public function getRef() {
  71      return id(new DoorkeeperObjectRef())
  72        ->setApplicationType($this->getApplicationType())
  73        ->setApplicationDomain($this->getApplicationDomain())
  74        ->setObjectType($this->getObjectType())
  75        ->setObjectID($this->getObjectID());
  76    }
  77  
  78    public function save() {
  79      if (!$this->objectKey) {
  80        $this->objectKey = $this->getObjectKey();
  81      }
  82  
  83      return parent::save();
  84    }
  85  
  86  
  87  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  88  
  89    public function getCapabilities() {
  90      return array(
  91        PhabricatorPolicyCapability::CAN_VIEW,
  92      );
  93    }
  94  
  95    public function getPolicy($capability) {
  96      return $this->viewPolicy;
  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  }


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