Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Access / AccessArgumentsResolverFactory.php
1 <?php
2
3 namespace Drupal\Core\Access;
4
5 use Drupal\Component\Utility\ArgumentsResolver;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Drupal\Core\Session\AccountInterface;
8 use Symfony\Component\HttpFoundation\Request;
9
10 /**
11  * Resolves the arguments to pass to an access check callable.
12  */
13 class AccessArgumentsResolverFactory implements AccessArgumentsResolverFactoryInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getArgumentsResolver(RouteMatchInterface $route_match, AccountInterface $account, Request $request = NULL) {
19     $route = $route_match->getRouteObject();
20
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();
24
25     $upcasted_route_arguments = $route_match->getParameters()->all();
26
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;
35     }
36
37     return new ArgumentsResolver($raw_route_arguments, $upcasted_route_arguments, $wildcard_arguments);
38   }
39
40 }