[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class AlmanacInterface 4 extends AlmanacDAO 5 implements PhabricatorPolicyInterface { 6 7 protected $devicePHID; 8 protected $networkPHID; 9 protected $address; 10 protected $port; 11 12 private $device = self::ATTACHABLE; 13 private $network = self::ATTACHABLE; 14 15 public static function initializeNewInterface() { 16 return id(new AlmanacInterface()); 17 } 18 19 public function getConfiguration() { 20 return array( 21 self::CONFIG_AUX_PHID => true, 22 self::CONFIG_COLUMN_SCHEMA => array( 23 'address' => 'text64', 24 'port' => 'uint32', 25 ), 26 self::CONFIG_KEY_SCHEMA => array( 27 'key_location' => array( 28 'columns' => array('networkPHID', 'address', 'port'), 29 ), 30 'key_device' => array( 31 'columns' => array('devicePHID'), 32 ), 33 ), 34 ) + parent::getConfiguration(); 35 } 36 37 public function generatePHID() { 38 return PhabricatorPHID::generateNewPHID( 39 AlmanacInterfacePHIDType::TYPECONST); 40 } 41 42 public function getDevice() { 43 return $this->assertAttached($this->device); 44 } 45 46 public function attachDevice(AlmanacDevice $device) { 47 $this->device = $device; 48 return $this; 49 } 50 51 public function getNetwork() { 52 return $this->assertAttached($this->network); 53 } 54 55 public function attachNetwork(AlmanacNetwork $network) { 56 $this->network = $network; 57 return $this; 58 } 59 60 public function toAddress() { 61 return AlmanacAddress::newFromParts( 62 $this->getNetworkPHID(), 63 $this->getAddress(), 64 $this->getPort()); 65 } 66 67 public function getAddressHash() { 68 return $this->toAddress()->toHash(); 69 } 70 71 public function renderDisplayAddress() { 72 return $this->getAddress().':'.$this->getPort(); 73 } 74 75 76 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 77 78 79 public function getCapabilities() { 80 return array( 81 PhabricatorPolicyCapability::CAN_VIEW, 82 PhabricatorPolicyCapability::CAN_EDIT, 83 ); 84 } 85 86 public function getPolicy($capability) { 87 return $this->getDevice()->getPolicy($capability); 88 } 89 90 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 91 return $this->getDevice()->hasAutomaticCapability($capability, $viewer); 92 } 93 94 public function describeAutomaticCapability($capability) { 95 return array( 96 pht('An interface inherits the policies of the device it belongs to.'), 97 pht( 98 'You must be able to view the network an interface resides on to '. 99 'view the interface.'), 100 ); 101 } 102 103 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |