class IncidentReportEvent

Same name in other branches
  1. 4.0.x modules/events_example/src/Event/IncidentReportEvent.php \Drupal\events_example\Event\IncidentReportEvent

Wraps a incident report event for event subscribers.

Whenever there is additional contextual data that you want to provide to the event subscribers when dispatching an event you should create a new class that extends \Symfony\Component\EventDispatcher\Event.

See \Drupal\Core\Config\ConfigCrudEvent for an example of this in core.

Hierarchy

  • class \Drupal\events_example\Event\IncidentReportEvent extends \Symfony\Contracts\EventDispatcher\Event

Expanded class hierarchy of IncidentReportEvent

See also

\Drupal\Core\Config\ConfigCrudEvent

Related topics

2 files declare their use of IncidentReportEvent
EventsExampleForm.php in modules/events_example/src/Form/EventsExampleForm.php
EventsExampleSubscriber.php in modules/events_example/src/EventSubscriber/EventsExampleSubscriber.php

File

modules/events_example/src/Event/IncidentReportEvent.php, line 20

Namespace

Drupal\events_example\Event
View source
class IncidentReportEvent extends Event {
    
    /**
     * Incident type.
     *
     * @var string
     */
    protected $type;
    
    /**
     * Detailed incident report.
     *
     * @var string
     */
    protected $report;
    
    /**
     * Constructs an incident report event object.
     *
     * @param string $type
     *   The incident report type.
     * @param string $report
     *   A detailed description of the incident provided by the reporter.
     */
    public function __construct($type, $report) {
        $this->type = $type;
        $this->report = $report;
    }
    
    /**
     * Get the incident type.
     *
     * @return string
     *   The type of report.
     */
    public function getType() {
        return $this->type;
    }
    
    /**
     * Get the detailed incident report.
     *
     * @return string
     *   The text of the report.
     */
    public function getReport() {
        return $this->report;
    }

}

Members

Title Sort descending Modifiers Object type Summary
IncidentReportEvent::$report protected property Detailed incident report.
IncidentReportEvent::$type protected property Incident type.
IncidentReportEvent::getReport public function Get the detailed incident report.
IncidentReportEvent::getType public function Get the incident type.
IncidentReportEvent::__construct public function Constructs an incident report event object.