You are here

function responsive_menu_get_flyleft_attribute in Responsive and off-canvas menu 8.2

Same name and namespace in other branches
  1. 8.3 responsive_menu.module \responsive_menu_get_flyleft_attribute()
  2. 4.4.x responsive_menu.module \responsive_menu_get_flyleft_attribute()
  3. 4.0.x responsive_menu.module \responsive_menu_get_flyleft_attribute()
  4. 4.1.x responsive_menu.module \responsive_menu_get_flyleft_attribute()
  5. 4.3.x responsive_menu.module \responsive_menu_get_flyleft_attribute()

Determines whether the flyleft menu link attribute has been set.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $menu_link_content_plugin: The menu link content plugin.

Return value

bool Return a TRUE or FALSE depending on whether the flyleft class was found.

1 call to responsive_menu_get_flyleft_attribute()
responsive_menu_assign_attributes_to_item in ./responsive_menu.module
Assigns the flyleft attribute to the menu items.

File

./responsive_menu.module, line 344
Contains procedural code.

Code

function responsive_menu_get_flyleft_attribute(MenuLinkInterface $menu_link_content_plugin) {
  try {
    $plugin_id = $menu_link_content_plugin
      ->getPluginId();
  } catch (PluginNotFoundException $e) {
    return FALSE;
  }
  if (strpos($plugin_id, ':') === FALSE) {
    return FALSE;
  }
  list($entity_type, $uuid) = explode(':', $plugin_id, 2);
  if ($entity_type == 'menu_link_content') {
    $entity = \Drupal::entityManager()
      ->loadEntityByUuid($entity_type, $uuid);
    if ($entity) {
      $options = $entity->link
        ->first()->options;
      $attributes = isset($options['attributes']) ? $options['attributes'] : [];
      if (isset($attributes['flyleft'])) {
        return TRUE;
      }
    }
  }
  return FALSE;
}