Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigTableSchema.php
| <?php | <?php | ||||
| final class PhabricatorConfigTableSchema | final class PhabricatorConfigTableSchema | ||||
| extends PhabricatorConfigStorageSchema { | extends PhabricatorConfigStorageSchema { | ||||
| private $collation; | private $collation; | ||||
| private $engine; | private $engine; | ||||
| private $columns = array(); | private $columns = array(); | ||||
| private $keys = array(); | private $keys = array(); | ||||
| private $persistenceType = self::PERSISTENCE_DATA; | |||||
| const PERSISTENCE_DATA = 'data'; | |||||
| const PERSISTENCE_CACHE = 'cache'; | |||||
| const PERSISTENCE_INDEX = 'index'; | |||||
| public function addColumn(PhabricatorConfigColumnSchema $column) { | public function addColumn(PhabricatorConfigColumnSchema $column) { | ||||
| $key = $column->getName(); | $key = $column->getName(); | ||||
| if (isset($this->columns[$key])) { | if (isset($this->columns[$key])) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht('Trying to add duplicate column "%s"!', $key)); | pht('Trying to add duplicate column "%s"!', $key)); | ||||
| } | } | ||||
| $this->columns[$key] = $column; | $this->columns[$key] = $column; | ||||
| Show All 22 Lines | final class PhabricatorConfigTableSchema | ||||
| public function getKeys() { | public function getKeys() { | ||||
| return $this->keys; | return $this->keys; | ||||
| } | } | ||||
| public function getKey($key) { | public function getKey($key) { | ||||
| return idx($this->getKeys(), $key); | return idx($this->getKeys(), $key); | ||||
| } | } | ||||
| public function setPersistenceType($persistence_type) { | |||||
| $this->persistenceType = $persistence_type; | |||||
| return $this; | |||||
| } | |||||
| public function getPersistenceType() { | |||||
| return $this->persistenceType; | |||||
| } | |||||
| public function getPersistenceTypeDisplayName() { | |||||
| $map = array( | |||||
| self::PERSISTENCE_DATA => pht('Data'), | |||||
| self::PERSISTENCE_CACHE => pht('Cache'), | |||||
| self::PERSISTENCE_INDEX => pht('Index'), | |||||
| ); | |||||
| $type = $this->getPersistenceType(); | |||||
| return idx($map, $type, $type); | |||||
| } | |||||
| protected function getSubschemata() { | protected function getSubschemata() { | ||||
| // NOTE: Keys and columns may have the same name, so make sure we return | // NOTE: Keys and columns may have the same name, so make sure we return | ||||
| // everything. | // everything. | ||||
| return array_merge( | return array_merge( | ||||
| array_values($this->columns), | array_values($this->columns), | ||||
| array_values($this->keys)); | array_values($this->keys)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||