function NavigationMenuLinkTreeManipulators::isEnabledAndAccessible

Checks whether the menu link tree element is accessible and enabled.

Generally, the 'checkAccess' manipulator should run before this manipulator does, so the access objects should be set on all the links, but if it is not, treat the link as accessible for the purpose of adding the overview child link.

Parameters

\Drupal\Core\Menu\MenuLinkTreeElement $element: The menu link tree element to be checked.

Return value

bool TRUE if the menu link tree element is enabled and has access allowed.

2 calls to NavigationMenuLinkTreeManipulators::isEnabledAndAccessible()
NavigationMenuLinkTreeManipulators::addSecondLevelOverviewLinks in core/modules/navigation/src/Menu/NavigationMenuLinkTreeManipulators.php
Adds an "overview" child link to second level menu links with children.
NavigationMenuLinkTreeManipulators::shouldAddOverviewLink in core/modules/navigation/src/Menu/NavigationMenuLinkTreeManipulators.php
Whether a menu tree element should have an overview link added to it.

File

core/modules/navigation/src/Menu/NavigationMenuLinkTreeManipulators.php, line 130

Class

NavigationMenuLinkTreeManipulators
Provides a menu link tree manipulator for the navigation menu block.

Namespace

Drupal\navigation\Menu

Code

protected function isEnabledAndAccessible(MenuLinkTreeElement $element) : bool {
  return $element->link
    ->isEnabled() && (!isset($element->access) || $element->access
    ->isAllowed());
}

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