function Url::access

Same name in other branches
  1. 9 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::access()
  2. 10 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::access()
  3. 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 $account: (optional) Run access checks for this account. Defaults to the current user.

Return value

bool Returns TRUE if the user has access to the url, otherwise FALSE.

File

core/lib/Drupal/Core/Url.php, line 816

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public function access(AccountInterface $account = NULL) {
    if ($this->isRouted()) {
        return $this->accessManager()
            ->checkNamedRoute($this->getRouteName(), $this->getRouteParameters(), $account);
    }
    return TRUE;
}

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