Path: blob/master/src/applications/config/schema/PhabricatorConfigTableSchema.php
12256 views
<?php12final class PhabricatorConfigTableSchema3extends PhabricatorConfigStorageSchema {45private $collation;6private $engine;7private $columns = array();8private $keys = array();9private $persistenceType = self::PERSISTENCE_DATA;1011const PERSISTENCE_DATA = 'data';12const PERSISTENCE_CACHE = 'cache';13const PERSISTENCE_INDEX = 'index';1415public function addColumn(PhabricatorConfigColumnSchema $column) {16$key = $column->getName();17if (isset($this->columns[$key])) {18throw new Exception(19pht('Trying to add duplicate column "%s"!', $key));20}21$this->columns[$key] = $column;22return $this;23}2425public function addKey(PhabricatorConfigKeySchema $key) {26$name = $key->getName();27if (isset($this->keys[$name])) {28throw new Exception(29pht('Trying to add duplicate key "%s"!', $name));30}31$key->setTable($this);32$this->keys[$name] = $key;33return $this;34}3536public function getColumns() {37return $this->columns;38}3940public function getColumn($key) {41return idx($this->getColumns(), $key);42}4344public function getKeys() {45return $this->keys;46}4748public function getKey($key) {49return idx($this->getKeys(), $key);50}5152public function setPersistenceType($persistence_type) {53$this->persistenceType = $persistence_type;54return $this;55}5657public function getPersistenceType() {58return $this->persistenceType;59}6061public function getPersistenceTypeDisplayName() {62$map = array(63self::PERSISTENCE_DATA => pht('Data'),64self::PERSISTENCE_CACHE => pht('Cache'),65self::PERSISTENCE_INDEX => pht('Index'),66);6768$type = $this->getPersistenceType();6970return idx($map, $type, $type);71}7273protected function getSubschemata() {74// NOTE: Keys and columns may have the same name, so make sure we return75// everything.7677return array_merge(78array_values($this->columns),79array_values($this->keys));80}8182public function setCollation($collation) {83$this->collation = $collation;84return $this;85}8687public function getCollation() {88return $this->collation;89}9091public function setEngine($engine) {92$this->engine = $engine;93return $this;94}9596public function getEngine() {97return $this->engine;98}99100protected function compareToSimilarSchema(101PhabricatorConfigStorageSchema $expect) {102103$issues = array();104if ($this->getCollation() != $expect->getCollation()) {105$issues[] = self::ISSUE_COLLATION;106}107108if ($this->getEngine() != $expect->getEngine()) {109$issues[] = self::ISSUE_ENGINE;110}111112return $issues;113}114115public function newEmptyClone() {116$clone = clone $this;117$clone->columns = array();118$clone->keys = array();119return $clone;120}121122}123124125