protected function DefaultMenuLinkTreeManipulators::menuLinkCheckAccess in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::menuLinkCheckAccess()
- 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.
File
- core/
lib/ Drupal/ Core/ Menu/ DefaultMenuLinkTreeManipulators.php, line 197
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();
}