3 final class AlmanacNetwork
6 PhabricatorApplicationTransactionInterface
,
7 PhabricatorPolicyInterface
,
8 PhabricatorDestructibleInterface
,
9 PhabricatorNgramsInterface
,
10 PhabricatorConduitResultInterface
{
13 protected $viewPolicy;
14 protected $editPolicy;
16 public static function initializeNewNetwork() {
17 return id(new AlmanacNetwork())
18 ->setViewPolicy(PhabricatorPolicies
::POLICY_USER
)
19 ->setEditPolicy(PhabricatorPolicies
::POLICY_ADMIN
);
22 protected function getConfiguration() {
24 self
::CONFIG_AUX_PHID
=> true,
25 self
::CONFIG_COLUMN_SCHEMA
=> array(
28 self
::CONFIG_KEY_SCHEMA
=> array(
30 'columns' => array('name'),
34 ) + parent
::getConfiguration();
37 public function getPHIDType() {
38 return AlmanacNetworkPHIDType
::TYPECONST
;
41 public function getURI() {
43 '/almanac/network/%s/',
48 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
51 public function getApplicationTransactionEditor() {
52 return new AlmanacNetworkEditor();
55 public function getApplicationTransactionTemplate() {
56 return new AlmanacNetworkTransaction();
60 /* -( PhabricatorPolicyInterface )----------------------------------------- */
63 public function getCapabilities() {
65 PhabricatorPolicyCapability
::CAN_VIEW
,
66 PhabricatorPolicyCapability
::CAN_EDIT
,
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();
79 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
84 /* -( PhabricatorDestructibleInterface )----------------------------------- */
87 public function destroyObjectPermanently(
88 PhabricatorDestructionEngine
$engine) {
90 $interfaces = id(new AlmanacInterfaceQuery())
91 ->setViewer($engine->getViewer())
92 ->withNetworkPHIDs(array($this->getPHID()))
95 foreach ($interfaces as $interface) {
96 $engine->destroyObject($interface);
103 /* -( PhabricatorNgramsInterface )----------------------------------------- */
106 public function newNgrams() {
108 id(new AlmanacNetworkNameNgrams())
109 ->setValue($this->getName()),
114 /* -( PhabricatorConduitResultInterface )---------------------------------- */
117 public function getFieldSpecificationsForConduit() {
119 id(new PhabricatorConduitSearchFieldSpecification())
122 ->setDescription(pht('The name of the network.')),
126 public function getFieldValuesForConduit() {
128 'name' => $this->getName(),
132 public function getConduitSearchAttachments() {