You are here

protected function MenuLinkItem::getMenuNames in Menu Link (Field) 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldType/MenuLinkItem.php \Drupal\menu_link\Plugin\Field\FieldType\MenuLinkItem::getMenuNames()

Returns available menu names.

Return value

string[] Returns menu labels, keyed by menu ID.

1 call to MenuLinkItem::getMenuNames()
MenuLinkItem::fieldSettingsForm in src/Plugin/Field/FieldType/MenuLinkItem.php
Returns a form for the field-level settings.

File

src/Plugin/Field/FieldType/MenuLinkItem.php, line 324

Class

MenuLinkItem
Defines a menu link field type which stores the link, parent and menu.

Namespace

Drupal\menu_link\Plugin\Field\FieldType

Code

protected function getMenuNames() {
  if ($custom_menus = Menu::loadMultiple()) {
    foreach ($custom_menus as $menu_name => $menu) {
      $custom_menus[$menu_name] = $menu
        ->label();
    }
    asort($custom_menus);
  }
  return $custom_menus;
}