function TestSubscriber::handleEvent
Adds validation results to a stage event.
Parameters
\Drupal\package_manager\Event\StageEvent $event: The event object.
File
-
core/
modules/ package_manager/ tests/ modules/ package_manager_test_validation/ src/ EventSubscriber/ TestSubscriber.php, line 126
Class
- TestSubscriber
- Defines an event subscriber for testing validation of Package Manager events.
Namespace
Drupal\package_manager_test_validation\EventSubscriberCode
public function handleEvent(StageEvent $event) : void {
$results = $this->state
->get(self::getStateKey(get_class($event)), []);
// Record that value of maintenance mode for each event.
$this->state
->set(get_class($event) . '.' . 'system.maintenance_mode', $this->state
->get('system.maintenance_mode'));
if ($results instanceof \Throwable) {
throw $results;
}
elseif ($results === 'exit') {
exit;
}
elseif (is_string($results)) {
\Drupal::messenger()->addStatus($results);
return;
}
/** @var \Drupal\package_manager\ValidationResult $result */
foreach ($results as $result) {
$event->addResult($result);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.