function Schema::getTableDefinition

Gets a specific table definition.

Parameters

string $name: The name of the Table object to return.

Return value

Table The Table object.

Throws

\Drupal\Core\Database\Exception\SchemaDefinitionException When the requested table is missing.

File

core/lib/Drupal/Core/Database/SchemaDefinition/Schema.php, line 71

Class

Schema
Describes a database schema as a collection of database objects.

Namespace

Drupal\Core\Database\SchemaDefinition

Code

public function getTableDefinition(string $name) : Table {
  $ret = array_find($this->tables, function (Table $table) use ($name) : bool {
    return $table->name === $name;
  });
  if (!$ret) {
    throw new SchemaDefinitionException("Schema {$this->name} does not define a table named {$name}");
  }
  return $ret;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.