private function applyScriptFromController(View\ScriptAwareInterface $renderer, callable $controller) { $controller = new Reflection\CallableReflector($controller); if ($controller->getReflector() instanceof Reflection\MethodReflector) { $renderer->setScript($this->formatScript($controller->getReflector())); } }
private function resolveCommand($command, $controller) { $controller = new Reflection\CallableReflector($controller); $docblock = $controller->getReflector()->getDocBlock(); if (!$docblock->hasTag($this->config['tag'])) { return; } $params = []; foreach ($docblock->getTags('param') as $tag) { $params[] = ['name' => $tag->getName(), 'type' => $tag->getType(), 'description' => $tag->getDescription()]; } return ['command' => $command, 'description' => $docblock->getDescription(), 'params' => $params]; }
public function __invoke(callable $controller) { $parameters = []; $controller = new Reflection\CallableReflector($controller); $instance = $controller->getInstance(); // If the controller is an instance, we have already injected // dependencies into it's constructor. To give the user the most from // the caller, we now inject named parameters into the method being // called. // // If the controller is just a callable, we simply inject dependencies // matching the parameter names into the callable since this is the // only chance it will have access to dependencies in the container. foreach ($controller->getReflector()->getParameters() as $parameter) { if ($instance && $this->request) { if ($this->request->hasParam($parameter->getName())) { $parameters[] = $this->request->getParam($parameter->getName()); } } elseif ($container = $this->container) { $parameters[] = $container($parameter->getName()); } } return $controller->invokeArgs($parameters) ?: []; }