You are here

protected function ControllerResolver::doGetArguments in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/http-kernel/Controller/ControllerResolver.php \Symfony\Component\HttpKernel\Controller\ControllerResolver::doGetArguments()
  2. 8.0 core/lib/Drupal/Core/Controller/ControllerResolver.php \Drupal\Core\Controller\ControllerResolver::doGetArguments()
Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Controller/ControllerResolver.php \Symfony\Component\HttpKernel\Controller\ControllerResolver::doGetArguments()
1 call to ControllerResolver::doGetArguments()
ControllerResolver::getArguments in vendor/symfony/http-kernel/Controller/ControllerResolver.php
Returns the arguments to pass to the controller.
1 method overrides ControllerResolver::doGetArguments()
ControllerResolver::doGetArguments in core/lib/Drupal/Core/Controller/ControllerResolver.php

File

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

Class

ControllerResolver
ControllerResolver.

Namespace

Symfony\Component\HttpKernel\Controller

Code

protected function doGetArguments(Request $request, $controller, array $parameters) {
  $attributes = $request->attributes
    ->all();
  $arguments = array();
  foreach ($parameters as $param) {
    if (array_key_exists($param->name, $attributes)) {
      $arguments[] = $attributes[$param->name];
    }
    elseif ($param
      ->getClass() && $param
      ->getClass()
      ->isInstance($request)) {
      $arguments[] = $request;
    }
    elseif ($param
      ->isDefaultValueAvailable()) {
      $arguments[] = $param
        ->getDefaultValue();
    }
    else {
      if (is_array($controller)) {
        $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);
      }
      elseif (is_object($controller)) {
        $repr = get_class($controller);
      }
      else {
        $repr = $controller;
      }
      throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name));
    }
  }
  return $arguments;
}