@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 124 lines 3.2 kB view raw
1<?php 2 3final 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 protected 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 DoorkeeperExternalObjectPHIDType::TYPECONST); 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 public function setDisplayName($display_name) { 87 return $this->setProperty('xobj.name.display', $display_name); 88 } 89 90 public function getDisplayName() { 91 return $this->getProperty('xobj.name.display', pht('External Object')); 92 } 93 94 public function setDisplayFullName($full_name) { 95 return $this->setProperty('xobj.name.display-full', $full_name); 96 } 97 98 public function getDisplayFullName() { 99 $full_name = $this->getProperty('xobj.name.display-full'); 100 101 if ($full_name !== null) { 102 return $full_name; 103 } 104 105 return $this->getDisplayName(); 106 } 107 108/* -( PhabricatorPolicyInterface )----------------------------------------- */ 109 110 public function getCapabilities() { 111 return array( 112 PhabricatorPolicyCapability::CAN_VIEW, 113 ); 114 } 115 116 public function getPolicy($capability) { 117 return $this->viewPolicy; 118 } 119 120 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 121 return false; 122 } 123 124}