You are here

public function EventsExampleSubscriber::notifyDefault in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 events_example/src/EventSubscriber/EventsExampleSubscriber.php \Drupal\events_example\EventSubscriber\EventsExampleSubscriber::notifyDefault()

Handle incidents not handled by the other handlers.

Parameters

\Drupal\events_example\Event\IncidentReportEvent $event: The event object containing the incident report.

File

modules/events_example/src/EventSubscriber/EventsExampleSubscriber.php, line 124

Class

EventsExampleSubscriber
Subscribe to IncidentEvents::NEW_REPORT events and react to new reports.

Namespace

Drupal\events_example\EventSubscriber

Code

public function notifyDefault(IncidentReportEvent $event) {
  $this
    ->messenger()
    ->addStatus($this
    ->t('Thank you for reporting this incident. This message was set by an event subscriber. See @method()', [
    '@method' => __METHOD__,
  ]));
  $event
    ->stopPropagation();
}