function ControllerResolver::createController
Returns a callable for the given controller.
Throws
\InvalidArgumentException When the controller cannot be created
1 call to ControllerResolver::createController()
- ControllerResolver::getController in vendor/
symfony/ http-kernel/ Controller/ ControllerResolver.php
File
-
vendor/
symfony/ http-kernel/ Controller/ ControllerResolver.php, line 112
Class
- ControllerResolver
- This implementation uses the '_controller' request attribute to determine the controller to execute.
Namespace
Symfony\Component\HttpKernel\ControllerCode
protected function createController(string $controller) : callable {
if (!str_contains($controller, '::')) {
$controller = $this->instantiateController($controller);
if (!\is_callable($controller)) {
throw new \InvalidArgumentException($this->getControllerError($controller));
}
return $controller;
}
[
$class,
$method,
] = explode('::', $controller, 2);
try {
$controller = [
$this->instantiateController($class),
$method,
];
} catch (\Error|\LogicException $e) {
try {
if ((new \ReflectionMethod($class, $method))->isStatic()) {
return $class . '::' . $method;
}
} catch (\ReflectionException) {
throw $e;
}
throw $e;
}
if (!\is_callable($controller)) {
throw new \InvalidArgumentException($this->getControllerError($controller));
}
return $controller;
}