class ConfigurationUpdateHookGenerator in Update helper 8
Update hook generator for generate:configuration:update console command.
@package Drupal\update_helper\Generator
Hierarchy
- class \Drupal\update_helper\Generator\ConfigurationUpdateHookGenerator extends \Drupal\Console\Core\Generator\Generator
Expanded class hierarchy of ConfigurationUpdateHookGenerator
1 file declares its use of ConfigurationUpdateHookGenerator
- CommandSubscriber.php in src/
Events/ CommandSubscriber.php
1 string reference to 'ConfigurationUpdateHookGenerator'
1 service uses ConfigurationUpdateHookGenerator
File
- src/
Generator/ ConfigurationUpdateHookGenerator.php, line 13
Namespace
Drupal\update_helper\GeneratorView source
class ConfigurationUpdateHookGenerator extends Generator {
/**
* Module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* AuthenticationProviderGenerator constructor.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* Extension manager.
*/
public function __construct(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
/**
* Get update hook function name.
*
* @param string $module_name
* Module name.
* @param string $update_number
* Update number.
*
* @return string
* Returns update hook function name.
*/
protected function getUpdateFunctionName($module_name, $update_number) {
return $module_name . '_update_' . $update_number;
}
/**
* Generator Update N function.
*
* @param string $module
* Module name where update will be generated.
* @param string $update_number
* Update number that will be used.
* @param string $description
* Description displayed for update hook function.
*/
public function generate($module, $update_number, $description = '') {
$module_path = $this->moduleHandler
->getModule($module)
->getPath();
$update_file = $module_path . '/' . $module . '.install';
$this
->addSkeletonDir(__DIR__ . '/../../templates/console');
$parameters = [
'description' => $description,
'module' => $module,
'update_hook_name' => $this
->getUpdateFunctionName($module, $update_number),
'file_exists' => file_exists($update_file),
];
$this
->renderFile('configuration_update_hook.php.twig', $update_file, $parameters, FILE_APPEND);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurationUpdateHookGenerator:: |
protected | property | Module handler service. | |
ConfigurationUpdateHookGenerator:: |
public | function | Generator Update N function. | |
ConfigurationUpdateHookGenerator:: |
protected | function | Get update hook function name. | |
ConfigurationUpdateHookGenerator:: |
public | function | AuthenticationProviderGenerator constructor. |