getArgumentsResolver example


  public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
    try {
      $callable = $this->controllerResolver->getControllerFromDefinition($route->getRequirement('_custom_access'));
    }
    catch (\InvalidArgumentException $e) {
      // The custom access controller method was not found.       throw new \BadMethodCallException(sprintf('The "%s" method is not callable as a _custom_access callback in route "%s"', $route->getRequirement('_custom_access')$route->getPath()));
    }

    $arguments_resolver = $this->argumentsResolverFactory->getArgumentsResolver($route_match$account);
    $arguments = $arguments_resolver->getArguments($callable);

    return call_user_func_array($callable$arguments);
  }

}

    $route = $route_match->getRouteObject();
    $checks = $route->getOption('_access_checks') ?: [];

    // Filter out checks which require the incoming request.     if (!isset($request)) {
      $checks = array_diff($checks$this->checkProvider->getChecksNeedRequest());
    }

    $result = AccessResult::neutral();
    if (!empty($checks)) {
      $arguments_resolver = $this->argumentsResolverFactory->getArgumentsResolver($route_match$account$request);
      $result = AccessResult::allowed();
      foreach ($checks as $service_id) {
        $result = $result->andIf($this->performCheck($service_id$arguments_resolver));
      }
    }
    return $return_as_object ? $result : $result->isAllowed();
  }

  /** * Performs the specified access check. * * @param string $service_id * The access check service ID to use. * @param \Drupal\Component\Utility\ArgumentsResolverInterface $arguments_resolver * The parametrized arguments resolver instance. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. * * @throws \Drupal\Core\Access\AccessException * Thrown when the access check returns an invalid value. */
Home | Imprint | This part of the site doesn't use cookies.