Exemplo n.º 1
0
 public function dispatch(RoutingContextInterface $context)
 {
     $dispatchable = $context->getDispatchable();
     if ($dispatchable instanceof DispatchableInterface) {
         $ref = new \ReflectionMethod(get_class($dispatchable), 'dispatch');
         return $dispatchable->dispatch($context);
     }
     if (is_array($dispatchable)) {
         $ref = new \ReflectionMethod(is_object($dispatchable[0]) ? get_class($dispatchable[0]) : $dispatchable[0], $dispatchable[1]);
     } elseif ($dispatchable instanceof \Closure) {
         $ref = new \ReflectionFunction($dispatchable);
     } else {
         $ref = (new \ReflectionClass($dispatchable))->getMethod('__invoke');
     }
     $args = $this->transformActionArguments($ref, $context);
     $chain = new ActionFilterChain($this->plugins->getActionFilters(), $ref, $dispatchable, $args, $context);
     return $chain->proceed();
 }