protected DefaultMenuLinkTreeManipulators::menuLinkCheckAccess(MenuLinkInterface $instance)
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 198
Class
- DefaultMenuLinkTreeManipulators
- Provides a couple of menu link tree manipulators.
Namespace
Drupal\Core\Menu
Code
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(); }
Please login to continue.