function Table::toArray
Converts the object to legacy array-based specifications.
@internal
Return value
array The legacy array-based specification.
Overrides SchemaDefinitionInterface::toArray
File
-
core/
lib/ Drupal/ Core/ Database/ SchemaDefinition/ Table.php, line 84
Class
- Table
- Describes a database table.
Namespace
Drupal\Core\Database\SchemaDefinitionCode
public function toArray() : array {
$spec = [];
if ($this->description !== NULL) {
$spec['description'] = $this->description;
}
if ($this->columns !== NULL) {
foreach ($this->columns as $column) {
$spec['fields'][$column->name] = $column->toArray();
}
}
if ($this->primaryKey !== NULL) {
$spec['primary key'] = $this->primaryKey
->toArray();
}
if ($this->uniqueKeys !== NULL) {
foreach ($this->uniqueKeys as $uniqueKey) {
$spec['unique keys'][$uniqueKey->name] = $uniqueKey->toArray();
}
}
if ($this->indexes !== NULL) {
foreach ($this->indexes as $index) {
$spec['indexes'][$index->name] = $index->toArray();
}
}
if ($this->foreignKeys !== NULL) {
foreach ($this->foreignKeys as $foreignKey) {
$spec['foreign keys'][$foreignKey->name] = $foreignKey->toArray();
}
}
if ($this->dbSpecificExtra !== NULL) {
foreach ($this->dbSpecificExtra as $extra) {
foreach ($extra as $key => $value) {
$spec[$key] = $value;
}
}
}
return $spec;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.