public function SinglePageSiteManager::isMenuItemRenderable in Single Page Site 8
Same name and namespace in other branches
- 2.x src/Manager/SinglePageSiteManager.php \Drupal\single_page_site\Manager\SinglePageSiteManager::isMenuItemRenderable()
- 2.0.x src/Manager/SinglePageSiteManager.php \Drupal\single_page_site\Manager\SinglePageSiteManager::isMenuItemRenderable()
Checks if a given menu items has to be rendered.
Parameters
\Drupal\Core\Menu\MenuLinkTreeElement $menu_item: MenuLinkTreeElement object with menu item value.
Return value
bool|array Returns TRUE/FALSE to indicate if has to be rendered.
File
- src/
Manager/ SinglePageSiteManager.php, line 232
Class
- SinglePageSiteManager
- Class SinglePageSiteManager.
Namespace
Drupal\single_page_site\ManagerCode
public function isMenuItemRenderable(MenuLinkTreeElement $menu_item) {
$plugin_definition = $menu_item->link
->getPluginDefinition();
if ($plugin_definition['route_name'] != '<front>' && !empty($plugin_definition['enabled'])) {
if (empty($this
->getMenuItemClass())) {
// If class is empty => all menu items.
return $plugin_definition;
}
elseif ($this->moduleHandler
->moduleExists('link_attributes')) {
// If menu item has class "hide" or class configured in config form, we should render it.
if (!empty($plugin_definition['options']['attributes']['class'])) {
$class = $plugin_definition['options']['attributes']['class'];
if (strpos($class, $this
->getMenuItemClass()) !== FALSE) {
return $plugin_definition;
}
}
}
}
return FALSE;
}