Example #1
0
 /**
  * @param BaseEvent|CollectorEntry $event
  *
  * @return BaseEvent
  */
 public function dispatch(BaseEvent $event) : BaseEvent
 {
     if (!$event instanceof CollectorEntry) {
         throw new InvalidArgumentException('Invalid event type. Expected ' . CollectorEntry::class);
     }
     $this->collection->sort();
     $collector = $event->getCollector();
     /** @var Route $handler */
     foreach ($this->router->match($event) as $handler) {
         $callback = $handler->getAction();
         $callback($collector);
     }
     return $event;
 }