EventDispatcher provides integration with Symfony EventDispatcher component for Drupal 7.

Module dependencies

Usage

  1. Register EventSubscriber class as a service by any understandable by Service Container method tagging service with event_subscriber tag.
  2. Dispatch an event with:
    
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class EventSubscriber implements EventSubscriberInterface {
    
      public function methodName($event, $eventName, $eventDispatcher) {
        // Do something...
      }
      
      public static function getSubscribedEvents() {
        return array('eventName' => array('methodName'));
      }
    
    }
    
    $event = new Event();
    $ed = Drupal::service('event_dispatcher');
    $ed->dispatch('eventName', $event);
    
    

Project information

Releases