ModuleCommands
Drush commands for working with module schemas.
- Full name:
\Drupal\helper\Drush\Commands\ModuleCommands - Parent class:
DrushCommands
Properties
moduleHandler
protected \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
updateHookRegistry
protected \Drupal\Core\Update\UpdateHookRegistry $updateHookRegistry
Methods
__construct
ModuleCommands constructor.
public __construct(\Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler, \Drupal\Core\Update\UpdateHookRegistry $updateHookRegistry): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$moduleHandler |
\Drupal\Core\Extension\ModuleHandlerInterface | |
| The module handler. | ||
$updateHookRegistry |
\Drupal\Core\Update\UpdateHookRegistry | |
| The update hook registry. |
getSchemaVersion
Gets the schema version for a module.
public getSchemaVersion(string $module): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$module |
string | |
| The module name, for example "system". |
setSchemaVersion
Sets the schema version for a module.
public setSchemaVersion(string $module, int|string $version): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$module |
string | |
| The module name, for example "system". | ||
$version |
int|string | |
| The version to set or the string | ||
| "current[+-]number" to set a relative value to the current version. |
Throws:
InvalidArgumentExceptionUserAbortExceptionRuntimeException
interactSchemaVersion
Sets the schema version for module.
public interactSchemaVersion(\Symfony\Component\Console\Input\InputInterface $input): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface |
resetPostUpdate
Resets a post-update hook for a module.
public resetPostUpdate(string $module, string $hook): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$module |
string | |
| The module name, for example "system". | ||
$hook |
string | |
| The post-update hook name. |
Throws:
InvalidArgumentExceptionUserAbortExceptionRuntimeException
interactResetPostUpdate
Interaction hook for the module:post-update:reset command.
public interactResetPostUpdate(\Symfony\Component\Console\Input\InputInterface $input): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface |
getModuleFromPostUpdateHookName
Extract the module name from a post-update hook.
protected getModuleFromPostUpdateHookName(string $hook): string
Parameters:
| Parameter | Type | Description |
|---|---|---|
$hook |
string | |
| The post-update hook name. |
Return Value:
The module name.
deleteSchemaVersion
Deletes the schema version for a module.
public deleteSchemaVersion(string $module): mixed
This is useful for removing leftover schemas of deleted modules.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$module |
string | |
| The module name, for example "system". |
cleanupSchemaVersion
Cleans up the schema versions for deleted modules.
public cleanupSchemaVersion(): mixed
validateModule
Validation hook to check that a module name is valid.
public validateModule(\Consolidation\AnnotatedCommand\CommandData $commandData): mixed
If the argument to be validated is not named $module, pass the argument name as the value of the validate-module-name annotation.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$commandData |
\Consolidation\AnnotatedCommand\CommandData | |
| The command data. |
validateModuleInstalled
Validates that a module is valid and installed.
protected validateModuleInstalled(string $module): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$module |
string | |
| The module name. |
Throws:
If the module is not installed.
- InvalidArgumentException
getAvailableSchemaVersions
Returns a list of possible schema versions for a module.
protected getAvailableSchemaVersions(string $module): int[]
Parameters:
| Parameter | Type | Description |
|---|---|---|
$module |
string | |
| The module name. |
Return Value:
An array of schema versions.