class Schema
Same name in this branch
- main core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema
- main core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema
- main core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema
- main core/tests/Drupal/Tests/Core/Database/Stub/Driver/Schema.php \Drupal\Tests\Core\Database\Stub\Driver\Schema
- main core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/Schema.php \Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses\Schema
- main core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema
Same name and namespace in other branches
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema
- 11.x core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema
- 11.x core/tests/Drupal/Tests/Core/Database/Stub/Driver/Schema.php \Drupal\Tests\Core\Database\Stub\Driver\Schema
- 11.x core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/Schema.php \Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses\Schema
- 11.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema
- 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema
- 10 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema
- 10 core/tests/Drupal/Tests/Core/Database/Stub/Driver/Schema.php \Drupal\Tests\Core\Database\Stub\Driver\Schema
- 10 core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/Schema.php \Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses\Schema
- 10 core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema
- 10 core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema
- 10 core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema
- 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema
- 9 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema
- 9 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema
- 9 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/Schema.php \Drupal\driver_test\Driver\Database\DrivertestMysql\Schema
- 9 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Schema.php \Drupal\driver_test\Driver\Database\DrivertestMysqlDeprecatedVersion\Schema
- 9 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/Schema.php \Drupal\driver_test\Driver\Database\DrivertestPgsql\Schema
- 9 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema
- 9 core/tests/Drupal/Tests/Core/Database/Stub/Driver/Schema.php \Drupal\Tests\Core\Database\Stub\Driver\Schema
- 9 core/tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefakeWithAllCustomClasses/Schema.php \Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\Schema
- 9 core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema
- 9 core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema
- 9 core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema
- 9 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema
- 8.9.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/Schema.php \Drupal\driver_test\Driver\Database\DrivertestMysql\Schema
- 8.9.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/Schema.php \Drupal\driver_test\Driver\Database\DrivertestPgsql\Schema
- 8.9.x core/tests/Drupal/Tests/Core/Database/Stub/Driver/Schema.php \Drupal\Tests\Core\Database\Stub\Driver\Schema
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema
- 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema
- 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema
- 8.9.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema
- 11.x core/lib/Drupal/Core/Database/SchemaDefinition/Schema.php \Drupal\Core\Database\SchemaDefinition\Schema
Describes a database schema as a collection of database objects.
Hierarchy
- class \Drupal\Core\Database\SchemaDefinition\Schema implements \Drupal\Core\Database\SchemaDefinition\SchemaDefinitionInterface
Expanded class hierarchy of Schema
9 files declare their use of Schema
- BatchStorage.php in core/
lib/ Drupal/ Core/ Batch/ BatchStorage.php - database.api.php in core/
lib/ Drupal/ Core/ Database/ database.api.php - Hooks related to the Database system and the Schema API.
- KernelTestBase.php in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - locale.install in core/
modules/ locale/ locale.install - Install, update, and uninstall functions for the Locale module.
- ModuleInstaller.php in core/
lib/ Drupal/ Core/ Extension/ ModuleInstaller.php
3 string references to 'Schema'
- ConnectionTest::providerGetDriverClass in core/
tests/ Drupal/ Tests/ Core/ Database/ ConnectionTest.php - Data provider for testGetDriverClass().
- HookCollectorPass::checkForProceduralOnlyHooks in core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php - Checks for hooks which can't be supported in classes.
- HookCollectorPass::collectModuleHookImplementations in core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php - Collects procedural and Attribute hook implementations.
File
-
core/
lib/ Drupal/ Core/ Database/ SchemaDefinition/ Schema.php, line 13
Namespace
Drupal\Core\Database\SchemaDefinitionView source
final class Schema implements SchemaDefinitionInterface {
/**
* Constructor.
*
* @param SchemaDefinitionType $type
* The type of Drupal feature providing the schema.
* @param string $name
* The schema name.
* @param list<Table> $tables
* A list of Table objects.
*/
public function __construct(public readonly SchemaDefinitionType $type, public readonly string $name, public readonly array $tables) {
$this->validate();
}
/**
* Validates the properties of the value object.
*
* @throws \Drupal\Core\Database\Exception\SchemaDefinitionException
*/
private function validate() : void {
if ($this->tables && !Inspector::assertAllObjects($this->tables, Table::class)) {
throw new SchemaDefinitionException("All members of the 'tables' argument of a Schema must be Table objects");
}
}
/**
* Returns the names of the tables.
*
* @return list<string>
* The names of the tables.
*/
public function tableNames() : array {
return array_map(fn(Table $table): string => $table->name, $this->tables);
}
/**
* Gets a specific table definition.
*
* @param string $name
* The name of the Table object to return.
*
* @return Table
* The Table object.
*
* @throws \Drupal\Core\Database\Exception\SchemaDefinitionException
* When the requested table is missing.
*/
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;
}
/**
* {@inheritdoc}
*/
public function toArray() : array {
$spec = [];
foreach ($this->tables as $table) {
$spec[$table->name] = $table->toArray();
}
return $spec;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|
| Schema::getTableDefinition | public | function | Gets a specific table definition. | |
| Schema::tableNames | public | function | Returns the names of the tables. | |
| Schema::toArray | public | function | Converts the object to legacy array-based specifications. | Overrides SchemaDefinitionInterface::toArray |
| Schema::validate | private | function | Validates the properties of the value object. | |
| Schema::__construct | public | function | Constructor. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.