function Url::access
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url::access()
- 10 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::access()
- 11.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url::access()
Checks this Url object against applicable access check services.
Determines whether the route is accessible or not.
Parameters
\Drupal\Core\Session\AccountInterface|null $account: (optional) Run access checks for this account. NULL for the current user.
bool $return_as_object: (optional) Defaults to FALSE.
Return value
bool|\Drupal\Core\Access\AccessResultInterface The access result. Returns a boolean if $return_as_object is FALSE (this is the default) and otherwise an AccessResultInterface object. When a boolean is returned, the result of AccessInterface::isAllowed() is returned, i.e. TRUE means access is explicitly allowed, FALSE means access is either explicitly forbidden or "no opinion".
File
-
core/
lib/ Drupal/ Core/ Url.php, line 824
Class
- Url
- Defines an object that holds information about a URL.
Namespace
Drupal\CoreCode
public function access(AccountInterface $account = NULL, $return_as_object = FALSE) {
if ($this->isRouted()) {
return $this->accessManager()
->checkNamedRoute($this->getRouteName(), $this->getRouteParameters(), $account, $return_as_object);
}
return $return_as_object ? AccessResult::allowed() : TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.