class CommandSubscriber in Update helper 8
Same name and namespace in other branches
- 2.x src/Events/CommandSubscriber.php \Drupal\update_helper\Events\CommandSubscriber
Subscriber for "generate:configuration:update" command.
Hierarchy
- class \Drupal\update_helper\Events\CommandSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of CommandSubscriber
1 string reference to 'CommandSubscriber'
1 service uses CommandSubscriber
File
- src/
Events/ CommandSubscriber.php, line 11
Namespace
Drupal\update_helper\EventsView source
class CommandSubscriber implements EventSubscriberInterface {
/**
* Update hook generator for configuration update command.
*
* @var \Drupal\update_helper\Generator\ConfigurationUpdateHookGenerator
*/
protected $generator;
/**
* Command subscriber class.
*
* @param \Drupal\update_helper\Generator\ConfigurationUpdateHookGenerator $generator
* Update hook generator service.
*/
public function __construct(ConfigurationUpdateHookGenerator $generator) {
$this->generator = $generator;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
UpdateHelperEvents::COMMAND_GCU_EXECUTE => [
[
'onExecute',
10,
],
],
];
}
/**
* Handles execute for configuration update generation to create update hook.
*
* @param \Drupal\update_helper\Events\CommandExecuteEvent $execute_event
* Command execute event.
*/
public function onExecute(CommandExecuteEvent $execute_event) {
// If command that triggered this event wasn't successful, then nothing
// should be created.
if (!$execute_event
->getSuccessful()) {
return;
}
// Get options provided by command as options or in interactive mode.
$options = $execute_event
->getOptions();
// Generate update hook entry.
$this->generator
->generate($execute_event
->getModule(), $execute_event
->getUpdateNumber(), $options['description']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommandSubscriber:: |
protected | property | Update hook generator for configuration update command. | |
CommandSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
CommandSubscriber:: |
public | function | Handles execute for configuration update generation to create update hook. | |
CommandSubscriber:: |
public | function | Command subscriber class. |