/** * Dispatch an event. Can be any event object which implements `PhpSchool\PhpWorkshop\Event\EventInterface`. * * @param EventInterface $event * @return EventInterface */ public function dispatch(EventInterface $event) { if (array_key_exists($event->getName(), $this->listeners)) { foreach ($this->listeners[$event->getName()] as $listener) { $listener($event); } } return $event; }
/** * @param EventInterface $event * @return EventInterface */ public function dispatch(EventInterface $event) { if (array_key_exists($event->getName(), $this->listeners)) { foreach ($this->listeners[$event->getName()] as $listener) { $listener($event); } } if (array_key_exists($event->getName(), $this->verifiers)) { foreach ($this->verifiers[$event->getName()] as $verifier) { $result = $verifier($event); //return type hints pls if ($result instanceof ResultInterface) { $this->resultAggregator->add($result); } else { //??!! } } } return $event; }