Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigTableSchema.php
<?php | <?php | ||||
final class PhabricatorConfigTableSchema extends Phobject { | final class PhabricatorConfigTableSchema | ||||
extends PhabricatorConfigStorageSchema { | |||||
private $name; | |||||
private $collation; | private $collation; | ||||
private $columns = array(); | private $columns = array(); | ||||
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; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getColumns() { | public function getColumns() { | ||||
return $this->columns; | return $this->columns; | ||||
} | } | ||||
public function getColumn($key) { | |||||
return idx($this->getColumns(), $key); | |||||
} | |||||
protected function getSubschemata() { | |||||
return $this->getColumns(); | |||||
} | |||||
public function setCollation($collation) { | public function setCollation($collation) { | ||||
$this->collation = $collation; | $this->collation = $collation; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCollation() { | public function getCollation() { | ||||
return $this->collation; | return $this->collation; | ||||
} | } | ||||
public function setName($name) { | public function compareToSimilarSchema( | ||||
$this->name = $name; | PhabricatorConfigStorageSchema $expect) { | ||||
return $this; | |||||
$issues = array(); | |||||
if ($this->getCollation() != $expect->getCollation()) { | |||||
$issues[] = self::ISSUE_COLLATION; | |||||
} | |||||
return $issues; | |||||
} | } | ||||
public function getName() { | public function newEmptyClone() { | ||||
return $this->name; | $clone = clone $this; | ||||
$clone->columns = array(); | |||||
return $clone; | |||||
} | } | ||||
} | } |