class SchemaInspector in Drupal 9
Provides methods to access modules' schema.
Hierarchy
- class \Drupal\TestTools\Extension\SchemaInspector
Expanded class hierarchy of SchemaInspector
2 files declare their use of SchemaInspector
- KernelTestBase.php in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - ModuleTestBase.php in core/
modules/ system/ tests/ src/ Functional/ Module/ ModuleTestBase.php
File
- core/
tests/ Drupal/ TestTools/ Extension/ SchemaInspector.php, line 10
Namespace
Drupal\TestTools\ExtensionView source
class SchemaInspector {
/**
* Returns the module's schema specification.
*
* This function can be used to retrieve a schema specification provided by
* hook_schema(), so it allows you to derive your tables from existing
* specifications.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $handler
* The module handler to use for calling schema hook.
* @param string $module
* The module to which the table belongs.
*
* @return array
* An array of schema definition provided by hook_schema().
*
* @see \hook_schema()
*/
public static function getTablesSpecification(ModuleHandlerInterface $handler, string $module) : array {
if ($handler
->loadInclude($module, 'install')) {
return $handler
->invoke($module, 'schema') ?? [];
}
return [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SchemaInspector:: |
public static | function | Returns the module's schema specification. |