Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/storage/AlmanacNetwork.php
<?php | <?php | ||||
final class AlmanacNetwork | final class AlmanacNetwork | ||||
extends AlmanacDAO | extends AlmanacDAO | ||||
implements | implements | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorDestructibleInterface, | PhabricatorDestructibleInterface, | ||||
PhabricatorNgramsInterface, | PhabricatorNgramsInterface, | ||||
PhabricatorConduitResultInterface { | PhabricatorConduitResultInterface { | ||||
protected $name; | protected $name; | ||||
protected $mailKey; | |||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
public static function initializeNewNetwork() { | public static function initializeNewNetwork() { | ||||
return id(new AlmanacNetwork()) | return id(new AlmanacNetwork()) | ||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER) | ->setViewPolicy(PhabricatorPolicies::POLICY_USER) | ||||
->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN); | ->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN); | ||||
} | } | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'name' => 'sort128', | 'name' => 'sort128', | ||||
'mailKey' => 'bytes20', | |||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_name' => array( | 'key_name' => array( | ||||
'columns' => array('name'), | 'columns' => array('name'), | ||||
'unique' => true, | 'unique' => true, | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function getPHIDType() { | ||||
return PhabricatorPHID::generateNewPHID(AlmanacNetworkPHIDType::TYPECONST); | return AlmanacNetworkPHIDType::TYPECONST; | ||||
} | |||||
public function save() { | |||||
if (!$this->mailKey) { | |||||
$this->mailKey = Filesystem::readRandomCharacters(20); | |||||
} | |||||
return parent::save(); | |||||
} | } | ||||
public function getURI() { | public function getURI() { | ||||
return '/almanac/network/'.$this->getID().'/'; | return urisprintf( | ||||
'/almanac/network/%s/', | |||||
$this->getID()); | |||||
} | } | ||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | ||||
public function getApplicationTransactionEditor() { | public function getApplicationTransactionEditor() { | ||||
return new AlmanacNetworkEditor(); | return new AlmanacNetworkEditor(); | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |