diff --git a/core/lib/Drupal/Core/Controller/ControllerResolver.php b/core/lib/Drupal/Core/Controller/ControllerResolver.php index ad2da51..a8f2b3c 100644 --- a/core/lib/Drupal/Core/Controller/ControllerResolver.php +++ b/core/lib/Drupal/Core/Controller/ControllerResolver.php @@ -7,13 +7,13 @@ namespace Drupal\Core\Controller; +use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Routing\RouteMatch; -use Psr\Log\LoggerInterface; +use Drupal\Core\Routing\RouteMatchInterface; +use Psr\Http\Message\ServerRequestInterface; +use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver; -use Drupal\Core\DependencyInjection\ClassResolverInterface; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Psr\Http\Message\ServerRequestInterface; /** * ControllerResolver to enhance controllers beyond Symfony's basic handling. @@ -151,7 +151,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete elseif ($param->getClass() && $param->getClass()->name === ServerRequestInterface::class) { $arguments[] = $this->httpMessageFactory->createRequest($request); } - elseif ($param->getClass() && ($param->getClass()->name == 'Drupal\Core\Routing\RouteMatchInterface' || is_subclass_of($param->getClass()->name, 'Drupal\Core\Routing\RouteMatchInterface'))) { + elseif ($param->getClass() && ($param->getClass()->name == RouteMatchInterface::class || is_subclass_of($param->getClass()->name, RouteMatchInterface::class))) { $arguments[] = RouteMatch::createFromRequest($request); } elseif ($param->isDefaultValueAvailable()) { diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php index 8550fc5..5c34cf3 100644 --- a/core/lib/Drupal/Core/Menu/menu.api.php +++ b/core/lib/Drupal/Core/Menu/menu.api.php @@ -122,6 +122,25 @@ * For example, the placeholder '{myvar}' in a route will become the $myvar * parameter to the method. * + * Additionally, if a parameter is typed to one of the following special classes + * the system will pass + * + * Additionally, there are three special parameters that a controller method + * may implement to cause the system to pass those values as well. + * + * - \Symfony\Component\HttpFoundation\Request: The raw Symfony request object. + * It is generally only useful if the controller needs access to the query + * parameters of the request. By convention, this parameter is usually named + * $request. + * - \Psr\Http\Message\ServerRequestInterface: The raw request, represented + * using the PSR-7 ServerRequest format. This object is derived as necessary + * from the Symfony request, so if either will suffice the Symfony request + * will be slightly more performant. By convention this parameter is usually + * named $request. + * - \Drupal\Core\Routing\RouteMatchInterface: The "route match" data from + * this request. This object contains various standard data derived from + * the request and routing process. Consult the interface for details. + * * Most controllers will need to display some information stored in the Drupal * database, which will involve using one or more Drupal services (see the * @link container Services and container topic @endlink). In order to properly