Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContainerControllerResolver.php

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\Controller

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal