class AccessArgumentsResolverFactory

Same name in other branches
  1. 9 core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php \Drupal\Core\Access\AccessArgumentsResolverFactory
  2. 10 core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php \Drupal\Core\Access\AccessArgumentsResolverFactory
  3. 11.x core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php \Drupal\Core\Access\AccessArgumentsResolverFactory

Resolves the arguments to pass to an access check callable.

Hierarchy

Expanded class hierarchy of AccessArgumentsResolverFactory

1 string reference to 'AccessArgumentsResolverFactory'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses AccessArgumentsResolverFactory
access_arguments_resolver_factory in core/core.services.yml
Drupal\Core\Access\AccessArgumentsResolverFactory

File

core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php, line 13

Namespace

Drupal\Core\Access
View source
class AccessArgumentsResolverFactory implements AccessArgumentsResolverFactoryInterface {
    
    /**
     * {@inheritdoc}
     */
    public function getArgumentsResolver(RouteMatchInterface $route_match, AccountInterface $account, Request $request = NULL) {
        $route = $route_match->getRouteObject();
        // Defaults for the parameters defined on the route object need to be added
        // to the raw arguments.
        $raw_route_arguments = $route_match->getRawParameters()
            ->all() + $route->getDefaults();
        $upcasted_route_arguments = $route_match->getParameters()
            ->all();
        // Parameters which are not defined on the route object, but still are
        // essential for access checking are passed as wildcards to the argument
        // resolver. An access-check method with a parameter of type Route,
        // RouteMatchInterface, AccountInterface or Request will receive those
        // arguments regardless of the parameter name.
        $wildcard_arguments = [
            $route,
            $route_match,
            $account,
        ];
        if (isset($request)) {
            $wildcard_arguments[] = $request;
        }
        return new ArgumentsResolver($raw_route_arguments, $upcasted_route_arguments, $wildcard_arguments);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AccessArgumentsResolverFactory::getArgumentsResolver public function Returns the arguments resolver to use when running access checks. Overrides AccessArgumentsResolverFactoryInterface::getArgumentsResolver

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.