@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 upstream/main 136 lines 3.2 kB view raw
1<?php 2 3final class AlmanacNetwork 4 extends AlmanacDAO 5 implements 6 PhabricatorApplicationTransactionInterface, 7 PhabricatorPolicyInterface, 8 PhabricatorDestructibleInterface, 9 PhabricatorNgramsInterface, 10 PhabricatorConduitResultInterface { 11 12 protected $name; 13 protected $viewPolicy; 14 protected $editPolicy; 15 16 public static function initializeNewNetwork() { 17 return id(new AlmanacNetwork()) 18 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 19 ->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN); 20 } 21 22 protected function getConfiguration() { 23 return array( 24 self::CONFIG_AUX_PHID => true, 25 self::CONFIG_COLUMN_SCHEMA => array( 26 'name' => 'sort128', 27 ), 28 self::CONFIG_KEY_SCHEMA => array( 29 'key_name' => array( 30 'columns' => array('name'), 31 'unique' => true, 32 ), 33 ), 34 ) + parent::getConfiguration(); 35 } 36 37 public function getPHIDType() { 38 return AlmanacNetworkPHIDType::TYPECONST; 39 } 40 41 public function getURI() { 42 return urisprintf( 43 '/almanac/network/%s/', 44 $this->getID()); 45 } 46 47 48/* -( PhabricatorApplicationTransactionInterface )------------------------- */ 49 50 51 public function getApplicationTransactionEditor() { 52 return new AlmanacNetworkEditor(); 53 } 54 55 public function getApplicationTransactionTemplate() { 56 return new AlmanacNetworkTransaction(); 57 } 58 59 60/* -( PhabricatorPolicyInterface )----------------------------------------- */ 61 62 63 public function getCapabilities() { 64 return array( 65 PhabricatorPolicyCapability::CAN_VIEW, 66 PhabricatorPolicyCapability::CAN_EDIT, 67 ); 68 } 69 70 public function getPolicy($capability) { 71 switch ($capability) { 72 case PhabricatorPolicyCapability::CAN_VIEW: 73 return $this->getViewPolicy(); 74 case PhabricatorPolicyCapability::CAN_EDIT: 75 return $this->getEditPolicy(); 76 } 77 } 78 79 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 80 return false; 81 } 82 83 84/* -( PhabricatorDestructibleInterface )----------------------------------- */ 85 86 87 public function destroyObjectPermanently( 88 PhabricatorDestructionEngine $engine) { 89 90 $interfaces = id(new AlmanacInterfaceQuery()) 91 ->setViewer($engine->getViewer()) 92 ->withNetworkPHIDs(array($this->getPHID())) 93 ->execute(); 94 95 foreach ($interfaces as $interface) { 96 $engine->destroyObject($interface); 97 } 98 99 $this->delete(); 100 } 101 102 103/* -( PhabricatorNgramsInterface )----------------------------------------- */ 104 105 106 public function newNgrams() { 107 return array( 108 id(new AlmanacNetworkNameNgrams()) 109 ->setValue($this->getName()), 110 ); 111 } 112 113 114/* -( PhabricatorConduitResultInterface )---------------------------------- */ 115 116 117 public function getFieldSpecificationsForConduit() { 118 return array( 119 id(new PhabricatorConduitSearchFieldSpecification()) 120 ->setKey('name') 121 ->setType('string') 122 ->setDescription(pht('The name of the network.')), 123 ); 124 } 125 126 public function getFieldValuesForConduit() { 127 return array( 128 'name' => $this->getName(), 129 ); 130 } 131 132 public function getConduitSearchAttachments() { 133 return array(); 134 } 135 136}