function DefaultMenuLinkTreeManipulators::menuLinkCheckAccess

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::menuLinkCheckAccess()
  2. 8.9.x core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::menuLinkCheckAccess()
  3. 10 core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::menuLinkCheckAccess()

Checks access for one menu link instance.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $instance: The menu link instance.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 call to DefaultMenuLinkTreeManipulators::menuLinkCheckAccess()
DefaultMenuLinkTreeManipulators::checkAccess in core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
Performs access checks of a menu tree.

File

core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php, line 183

Class

DefaultMenuLinkTreeManipulators
Provides a couple of menu link tree manipulators.

Namespace

Drupal\Core\Menu

Code

protected function menuLinkCheckAccess(MenuLinkInterface $instance) {
    $url = $instance->getUrlObject();
    if ($url->isRouted()) {
        return $this->accessManager
            ->checkNamedRoute($url->getRouteName(), $url->getRouteParameters(), $this->account, TRUE);
    }
    // Must be an external link.
    return AccessResult::allowed();
}

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