Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/storage/AlmanacNamespace.php
| <?php | <?php | ||||
| final class AlmanacNamespace | final class AlmanacNamespace | ||||
| extends AlmanacDAO | extends AlmanacDAO | ||||
| implements | implements | ||||
| PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
| PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
| PhabricatorProjectInterface, | PhabricatorProjectInterface, | ||||
| AlmanacPropertyInterface, | |||||
| PhabricatorDestructibleInterface, | PhabricatorDestructibleInterface, | ||||
| PhabricatorNgramsInterface, | PhabricatorNgramsInterface, | ||||
| PhabricatorConduitResultInterface { | PhabricatorConduitResultInterface { | ||||
| protected $name; | protected $name; | ||||
| protected $nameIndex; | protected $nameIndex; | ||||
| protected $mailKey; | protected $mailKey; | ||||
| protected $viewPolicy; | protected $viewPolicy; | ||||
| protected $editPolicy; | protected $editPolicy; | ||||
| private $almanacProperties = self::ATTACHABLE; | |||||
| public static function initializeNewNamespace() { | public static function initializeNewNamespace() { | ||||
| return id(new self()) | return id(new self()) | ||||
| ->setViewPolicy(PhabricatorPolicies::POLICY_USER) | ->setViewPolicy(PhabricatorPolicies::POLICY_USER) | ||||
| ->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN) | ->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN); | ||||
| ->attachAlmanacProperties(array()); | |||||
| } | } | ||||
| 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', | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | public static function loadRestrictedNamespace( | ||||
| if ($can_edit) { | if ($can_edit) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return $namespace; | return $namespace; | ||||
| } | } | ||||
| /* -( AlmanacPropertyInterface )------------------------------------------- */ | |||||
| public function attachAlmanacProperties(array $properties) { | |||||
| assert_instances_of($properties, 'AlmanacProperty'); | |||||
| $this->almanacProperties = mpull($properties, null, 'getFieldName'); | |||||
| return $this; | |||||
| } | |||||
| public function getAlmanacProperties() { | |||||
| return $this->assertAttached($this->almanacProperties); | |||||
| } | |||||
| public function hasAlmanacProperty($key) { | |||||
| $this->assertAttached($this->almanacProperties); | |||||
| return isset($this->almanacProperties[$key]); | |||||
| } | |||||
| public function getAlmanacProperty($key) { | |||||
| return $this->assertAttachedKey($this->almanacProperties, $key); | |||||
| } | |||||
| public function getAlmanacPropertyValue($key, $default = null) { | |||||
| if ($this->hasAlmanacProperty($key)) { | |||||
| return $this->getAlmanacProperty($key)->getFieldValue(); | |||||
| } else { | |||||
| return $default; | |||||
| } | |||||
| } | |||||
| public function getAlmanacPropertyFieldSpecifications() { | |||||
| return array(); | |||||
| } | |||||
| public function newAlmanacPropertyEditEngine() { | |||||
| throw new PhutilMethodNotImplementedException(); | |||||
| } | |||||
| public function getAlmanacPropertySetTransactionType() { | |||||
| throw new PhutilMethodNotImplementedException(); | |||||
| } | |||||
| public function getAlmanacPropertyDeleteTransactionType() { | |||||
| throw new PhutilMethodNotImplementedException(); | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| ); | ); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||