function ContainerControllerResolver::instantiateController
Overrides ControllerResolver::instantiateController
File
-
vendor/
symfony/ http-kernel/ Controller/ ContainerControllerResolver.php, line 33
Class
- ContainerControllerResolver
- A controller resolver searching for a controller in a psr-11 container when using the "service::method" notation.
Namespace
Symfony\Component\HttpKernel\ControllerCode
protected function instantiateController(string $class) : object {
$class = ltrim($class, '\\');
if ($this->container
->has($class)) {
return $this->container
->get($class);
}
try {
return parent::instantiateController($class);
} catch (\Error $e) {
}
$this->throwExceptionIfControllerWasRemoved($class, $e);
if ($e instanceof \ArgumentCountError) {
throw new \InvalidArgumentException(\sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e);
}
throw new \InvalidArgumentException(\sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e);
}