You are here

function responsive_menu_get_flyleft_attribute in Responsive and off-canvas menu 4.0.x

Same name and namespace in other branches
  1. 8.3 responsive_menu.module \responsive_menu_get_flyleft_attribute()
  2. 8.2 responsive_menu.module \responsive_menu_get_flyleft_attribute()
  3. 4.4.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 289
Contains procedural code.

Code

function responsive_menu_get_flyleft_attribute(MenuLinkInterface $menu_link_content_plugin) {
  $plugin_id = $menu_link_content_plugin
    ->getPluginId();
  if (strpos($plugin_id, ':') === FALSE) {
    return FALSE;
  }
  list($entity_type, $uuid) = explode(':', $plugin_id, 2);
  if ($entity_type == 'menu_link_content') {
    $entity = \Drupal::service('entity.repository')
      ->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;
}