3 namespace Drupal\Core\Access;
5 use Symfony\Component\HttpFoundation\Request;
6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\Core\Routing\RouteMatchInterface;
10 * Provides an interface for attaching and running access check services.
12 interface AccessManagerInterface {
15 * Checks a named route with parameters against applicable access check services.
17 * Determines whether the route is accessible or not.
19 * @param string $route_name
20 * The route to check access to.
21 * @param array $parameters
22 * Optional array of values to substitute into the route path pattern.
23 * @param \Drupal\Core\Session\AccountInterface $account
24 * (optional) Run access checks for this account. Defaults to the current
26 * @param bool $return_as_object
27 * (optional) Defaults to FALSE.
29 * @return bool|\Drupal\Core\Access\AccessResultInterface
30 * The access result. Returns a boolean if $return_as_object is FALSE (this
31 * is the default) and otherwise an AccessResultInterface object.
32 * When a boolean is returned, the result of AccessInterface::isAllowed() is
33 * returned, i.e. TRUE means access is explicitly allowed, FALSE means
34 * access is either explicitly forbidden or "no opinion".
36 public function checkNamedRoute($route_name, array $parameters = [], AccountInterface $account = NULL, $return_as_object = FALSE);
39 * Execute access checks against the incoming request.
41 * @param \Symfony\Component\HttpFoundation\Request $request
42 * The incoming request.
43 * @param \Drupal\Core\Session\AccountInterface $account
44 * (optional) Run access checks for this account. Defaults to the current
46 * @param bool $return_as_object
47 * (optional) Defaults to FALSE.
49 * @return bool|\Drupal\Core\Access\AccessResultInterface
50 * The access result. Returns a boolean if $return_as_object is FALSE (this
51 * is the default) and otherwise an AccessResultInterface object.
52 * When a boolean is returned, the result of AccessInterface::isAllowed() is
53 * returned, i.e. TRUE means access is explicitly allowed, FALSE means
54 * access is either explicitly forbidden or "no opinion".
56 public function checkRequest(Request $request, AccountInterface $account = NULL, $return_as_object = FALSE);
59 * Checks a route against applicable access check services.
61 * Determines whether the route is accessible or not.
63 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
65 * @param \Drupal\Core\Session\AccountInterface $account
66 * (optional) Run access checks for this account. Defaults to the current
68 * @param \Symfony\Component\HttpFoundation\Request $request
69 * Optional, a request. Only supply this parameter when checking the
70 * incoming request, do not specify when checking routes on output.
71 * @param bool $return_as_object
72 * (optional) Defaults to FALSE.
74 * @return bool|\Drupal\Core\Access\AccessResultInterface
75 * The access result. Returns a boolean if $return_as_object is FALSE (this
76 * is the default) and otherwise an AccessResultInterface object.
77 * When a boolean is returned, the result of AccessInterface::isAllowed() is
78 * returned, i.e. TRUE means access is explicitly allowed, FALSE means
79 * access is either explicitly forbidden or "no opinion".
81 public function check(RouteMatchInterface $route_match, AccountInterface $account = NULL, Request $request = NULL, $return_as_object = FALSE);