Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function fire($event, $context = null)
 {
     if (is_object($event) && !$event instanceof EventInterface) {
         throw new InvalidArgumentException("Only instances of EventInterface or event name can be fired.");
     }
     if (is_string($event)) {
         $event = new Event($event, $context);
     }
     /**
      * @var Event $event
      */
     if (empty($this->listeners[$event->name()])) {
         return $event->context();
     }
     foreach ($this->listeners[$event->name()] as $listener) {
         call_user_func($listener, $event);
         if ($event->isStopped()) {
             break;
         }
     }
     return $event->context();
 }
Exemplo n.º 2
0
 /**
  * @param object $parent
  * @param string $name
  * @param mixed  $context
  */
 public function __construct($parent, $name, $context)
 {
     $this->parent = $parent;
     parent::__construct($name, $context);
 }