3 final class DoorkeeperExternalObject
extends DoorkeeperDAO
4 implements PhabricatorPolicyInterface
{
7 protected $applicationType;
8 protected $applicationDomain;
12 protected $importerPHID;
13 protected $properties = array();
14 protected $viewPolicy;
16 protected function getConfiguration() {
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'),
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;
62 public function getObjectKey() {
63 $key = parent
::getObjectKey();
65 $key = $this->getRef()->getObjectKey();
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) {
105 return $this->getDisplayName();
108 /* -( PhabricatorPolicyInterface )----------------------------------------- */
110 public function getCapabilities() {
112 PhabricatorPolicyCapability
::CAN_VIEW
,
116 public function getPolicy($capability) {
117 return $this->viewPolicy
;
120 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {