Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / doorkeeper / storage / DoorkeeperExternalObject.php
bloba4ce41adacd37ce6f52d01251445988e229f076e
1 <?php
3 final class DoorkeeperExternalObject extends DoorkeeperDAO
4 implements PhabricatorPolicyInterface {
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;
16 protected function getConfiguration() {
17 return array(
18 self::CONFIG_AUX_PHID => true,
19 self::CONFIG_SERIALIZATION => array(
20 'properties' => self::SERIALIZATION_JSON,
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?',
31 self::CONFIG_KEY_SCHEMA => array(
32 'key_object' => array(
33 'columns' => array('objectKey'),
34 'unique' => true,
36 'key_full' => array(
37 'columns' => array(
38 'applicationType',
39 'applicationDomain',
40 'objectType',
41 'objectID',
45 ) + parent::getConfiguration();
48 public function generatePHID() {
49 return PhabricatorPHID::generateNewPHID(
50 DoorkeeperExternalObjectPHIDType::TYPECONST);
53 public function getProperty($key, $default = null) {
54 return idx($this->properties, $key, $default);
57 public function setProperty($key, $value) {
58 $this->properties[$key] = $value;
59 return $this;
62 public function getObjectKey() {
63 $key = parent::getObjectKey();
64 if ($key === null) {
65 $key = $this->getRef()->getObjectKey();
67 return $key;
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());
78 public function save() {
79 if (!$this->objectKey) {
80 $this->objectKey = $this->getObjectKey();
83 return parent::save();
86 public function setDisplayName($display_name) {
87 return $this->setProperty('xobj.name.display', $display_name);
90 public function getDisplayName() {
91 return $this->getProperty('xobj.name.display', pht('External Object'));
94 public function setDisplayFullName($full_name) {
95 return $this->setProperty('xobj.name.display-full', $full_name);
98 public function getDisplayFullName() {
99 $full_name = $this->getProperty('xobj.name.display-full');
101 if ($full_name !== null) {
102 return $full_name;
105 return $this->getDisplayName();
108 /* -( PhabricatorPolicyInterface )----------------------------------------- */
110 public function getCapabilities() {
111 return array(
112 PhabricatorPolicyCapability::CAN_VIEW,
116 public function getPolicy($capability) {
117 return $this->viewPolicy;
120 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
121 return false;