protected function DefaultMenuLinkTreeManipulators::menuLinkCheckAccess in Drupal 8
Same name and namespace in other branches
- 9 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 199
Class
- DefaultMenuLinkTreeManipulators
- Provides a couple of menu link tree manipulators.
Namespace
Drupal\Core\MenuCode
protected function menuLinkCheckAccess(MenuLinkInterface $instance) {
$access_result = NULL;
if ($this->account
->hasPermission('link to any page')) {
$access_result = AccessResult::allowed();
}
else {
$url = $instance
->getUrlObject();
// When no route name is specified, this must be an external link.
if (!$url
->isRouted()) {
$access_result = AccessResult::allowed();
}
else {
$access_result = $this->accessManager
->checkNamedRoute($url
->getRouteName(), $url
->getRouteParameters(), $this->account, TRUE);
}
}
return $access_result
->cachePerPermissions();
}