You are here

protected function ControllerResolver::createController in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-kernel/Controller/ControllerResolver.php \Symfony\Component\HttpKernel\Controller\ControllerResolver::createController()
  2. 8 core/lib/Drupal/Core/Controller/ControllerResolver.php \Drupal\Core\Controller\ControllerResolver::createController()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Controller/ControllerResolver.php \Symfony\Component\HttpKernel\Controller\ControllerResolver::createController()

Returns a callable for the given controller.

Parameters

string $controller A Controller string:

Return value

callable A PHP callable

Throws

\InvalidArgumentException

1 call to ControllerResolver::createController()
ControllerResolver::getController in vendor/symfony/http-kernel/Controller/ControllerResolver.php
This method looks for a '_controller' request attribute that represents the controller name (a string like ClassName::MethodName).
1 method overrides ControllerResolver::createController()
ControllerResolver::createController in core/lib/Drupal/Core/Controller/ControllerResolver.php
Returns a callable for the given controller.

File

vendor/symfony/http-kernel/Controller/ControllerResolver.php, line 138

Class

ControllerResolver
ControllerResolver.

Namespace

Symfony\Component\HttpKernel\Controller

Code

protected function createController($controller) {
  if (false === strpos($controller, '::')) {
    throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
  }
  list($class, $method) = explode('::', $controller, 2);
  if (!class_exists($class)) {
    throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
  }
  return array(
    $this
      ->instantiateController($class),
    $method,
  );
}