Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/storage/AlmanacService.php
<?php | <?php | ||||
final class AlmanacService | final class AlmanacService | ||||
extends AlmanacDAO | extends AlmanacDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorProjectInterface, | PhabricatorProjectInterface, | ||||
AlmanacPropertyInterface, | AlmanacPropertyInterface, | ||||
PhabricatorDestructibleInterface, | PhabricatorDestructibleInterface, | ||||
PhabricatorNgramsInterface, | PhabricatorNgramsInterface, | ||||
PhabricatorConduitResultInterface, | PhabricatorConduitResultInterface, | ||||
PhabricatorExtendedPolicyInterface { | PhabricatorExtendedPolicyInterface { | ||||
protected $name; | protected $name; | ||||
protected $nameIndex; | protected $nameIndex; | ||||
protected $mailKey; | |||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $serviceType; | protected $serviceType; | ||||
private $almanacProperties = self::ATTACHABLE; | private $almanacProperties = self::ATTACHABLE; | ||||
private $bindings = self::ATTACHABLE; | private $bindings = self::ATTACHABLE; | ||||
private $activeBindings = self::ATTACHABLE; | private $activeBindings = self::ATTACHABLE; | ||||
private $serviceImplementation = self::ATTACHABLE; | private $serviceImplementation = self::ATTACHABLE; | ||||
Show All 18 Lines | final class AlmanacService | ||||
} | } | ||||
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' => 'text128', | 'name' => 'text128', | ||||
'nameIndex' => 'bytes12', | 'nameIndex' => 'bytes12', | ||||
'mailKey' => 'bytes20', | |||||
'serviceType' => 'text64', | 'serviceType' => 'text64', | ||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_name' => array( | 'key_name' => array( | ||||
'columns' => array('nameIndex'), | 'columns' => array('nameIndex'), | ||||
'unique' => true, | 'unique' => true, | ||||
), | ), | ||||
'key_nametext' => array( | 'key_nametext' => array( | ||||
'columns' => array('name'), | 'columns' => array('name'), | ||||
), | ), | ||||
'key_servicetype' => array( | 'key_servicetype' => array( | ||||
'columns' => array('serviceType'), | 'columns' => array('serviceType'), | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function getPHIDType() { | ||||
return PhabricatorPHID::generateNewPHID(AlmanacServicePHIDType::TYPECONST); | return AlmanacServicePHIDType::TYPECONST; | ||||
} | } | ||||
public function save() { | public function save() { | ||||
AlmanacNames::validateName($this->getName()); | AlmanacNames::validateName($this->getName()); | ||||
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName()); | $this->nameIndex = PhabricatorHash::digestForIndex($this->getName()); | ||||
if (!$this->mailKey) { | |||||
$this->mailKey = Filesystem::readRandomCharacters(20); | |||||
} | |||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
public function getURI() { | public function getURI() { | ||||
return '/almanac/service/view/'.$this->getName().'/'; | return '/almanac/service/view/'.$this->getName().'/'; | ||||
} | } | ||||
public function getBindings() { | public function getBindings() { | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |