3 namespace Drupal\Core\Access;
5 use Drupal\Component\Utility\ArgumentsResolver;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Drupal\Core\Session\AccountInterface;
8 use Symfony\Component\HttpFoundation\Request;
11 * Resolves the arguments to pass to an access check callable.
13 class AccessArgumentsResolverFactory implements AccessArgumentsResolverFactoryInterface {
18 public function getArgumentsResolver(RouteMatchInterface $route_match, AccountInterface $account, Request $request = NULL) {
19 $route = $route_match->getRouteObject();
21 // Defaults for the parameters defined on the route object need to be added
22 // to the raw arguments.
23 $raw_route_arguments = $route_match->getRawParameters()->all() + $route->getDefaults();
25 $upcasted_route_arguments = $route_match->getParameters()->all();
27 // Parameters which are not defined on the route object, but still are
28 // essential for access checking are passed as wildcards to the argument
29 // resolver. An access-check method with a parameter of type Route,
30 // RouteMatchInterface, AccountInterface or Request will receive those
31 // arguments regardless of the parameter name.
32 $wildcard_arguments = [$route, $route_match, $account];
33 if (isset($request)) {
34 $wildcard_arguments[] = $request;
37 return new ArgumentsResolver($raw_route_arguments, $upcasted_route_arguments, $wildcard_arguments);