You are here

public function SimpleMegaMenuTwigExtension::hasMegaMenu in Simple Mega Menu 2.0.x

Same name and namespace in other branches
  1. 8 src/TwigExtension/SimpleMegaMenuTwigExtension.php \Drupal\simple_megamenu\TwigExtension\SimpleMegaMenuTwigExtension::hasMegaMenu()

Check if a mega menu is referenced by an Url object.

Parameters

\Drupal\Core\Url|string $url: The URL object used for the link.

Return value

bool TRUE if a simple mega menu entity is reference by the Url object.

1 call to SimpleMegaMenuTwigExtension::hasMegaMenu()
SimpleMegaMenuTwigExtension::viewMegaMenu in src/TwigExtension/SimpleMegaMenuTwigExtension.php
Render a mega menu in a view from an Url object.

File

src/TwigExtension/SimpleMegaMenuTwigExtension.php, line 88

Class

SimpleMegaMenuTwigExtension
Class SimpleMegaMenuTwigExtension.

Namespace

Drupal\simple_megamenu\TwigExtension

Code

public function hasMegaMenu(Url $url) {
  if (!$url instanceof Url) {
    return FALSE;
  }
  $menu_attributes = $url
    ->getOption('attributes');
  if (isset($menu_attributes['data-simple-mega-menu']) && !empty($menu_attributes['data-simple-mega-menu'])) {
    return TRUE;
  }
  return FALSE;
}