function EventsExampleSubscriber::notifyBatman
Same name in other branches
- 3.x modules/events_example/src/EventSubscriber/EventsExampleSubscriber.php \Drupal\events_example\EventSubscriber\EventsExampleSubscriber::notifyBatman()
Let Batman know about any events involving the Joker.
Parameters
\Drupal\events_example\Event\IncidentReportEvent $event: The event object containing the incident report.
File
-
modules/
events_example/ src/ EventSubscriber/ EventsExampleSubscriber.php, line 111
Class
- EventsExampleSubscriber
- Subscribe to IncidentEvents::NEW_REPORT events and react to new reports.
Namespace
Drupal\events_example\EventSubscriberCode
public function notifyBatman(IncidentReportEvent $event) {
if ($event->getType() == 'joker') {
$this->messenger()
->addStatus($this->t('Batman has been alerted. Thank you. This message was set by an event subscriber. See @method()', [
'@method' => __METHOD__,
]));
$event->stopPropagation();
}
}