Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / storage / AlmanacNetwork.php
bloba3dadee69bb99f103dc6e1805dcb250b8c6074ec
1 <?php
3 final class AlmanacNetwork
4 extends AlmanacDAO
5 implements
6 PhabricatorApplicationTransactionInterface,
7 PhabricatorPolicyInterface,
8 PhabricatorDestructibleInterface,
9 PhabricatorNgramsInterface,
10 PhabricatorConduitResultInterface {
12 protected $name;
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() {
23 return array(
24 self::CONFIG_AUX_PHID => true,
25 self::CONFIG_COLUMN_SCHEMA => array(
26 'name' => 'sort128',
28 self::CONFIG_KEY_SCHEMA => array(
29 'key_name' => array(
30 'columns' => array('name'),
31 'unique' => true,
34 ) + parent::getConfiguration();
37 public function getPHIDType() {
38 return AlmanacNetworkPHIDType::TYPECONST;
41 public function getURI() {
42 return urisprintf(
43 '/almanac/network/%s/',
44 $this->getID());
48 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
51 public function getApplicationTransactionEditor() {
52 return new AlmanacNetworkEditor();
55 public function getApplicationTransactionTemplate() {
56 return new AlmanacNetworkTransaction();
60 /* -( PhabricatorPolicyInterface )----------------------------------------- */
63 public function getCapabilities() {
64 return array(
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) {
80 return false;
84 /* -( PhabricatorDestructibleInterface )----------------------------------- */
87 public function destroyObjectPermanently(
88 PhabricatorDestructionEngine $engine) {
90 $interfaces = id(new AlmanacInterfaceQuery())
91 ->setViewer($engine->getViewer())
92 ->withNetworkPHIDs(array($this->getPHID()))
93 ->execute();
95 foreach ($interfaces as $interface) {
96 $engine->destroyObject($interface);
99 $this->delete();
103 /* -( PhabricatorNgramsInterface )----------------------------------------- */
106 public function newNgrams() {
107 return array(
108 id(new AlmanacNetworkNameNgrams())
109 ->setValue($this->getName()),
114 /* -( PhabricatorConduitResultInterface )---------------------------------- */
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.')),
126 public function getFieldValuesForConduit() {
127 return array(
128 'name' => $this->getName(),
132 public function getConduitSearchAttachments() {
133 return array();