OgMenuParentFormSelector.php in Organic Groups Menu (OG Menu) 8
File
src/OgMenuParentFormSelector.php
View source
<?php
namespace Drupal\og_menu;
use Drupal\Core\Menu\MenuParentFormSelector;
class OgMenuParentFormSelector extends MenuParentFormSelector {
protected $is_og_menu = FALSE;
public function parentSelectElement($menu_parent, $id = '', array $menus = NULL) {
if (strpos($menu_parent, 'ogmenu-') !== FALSE) {
$this->is_og_menu = TRUE;
}
return parent::parentSelectElement($menu_parent, $id, $menus);
}
protected function getMenuOptions(array $menu_names = NULL) {
$entity_type = 'menu';
if ($this->is_og_menu) {
$entity_type = 'ogmenu_instance';
}
$menus = $this->entityTypeManager
->getStorage($entity_type)
->loadMultiple($menu_names);
$options = array();
foreach ($menus as $menu) {
if ($this->is_og_menu) {
$options['ogmenu-' . $menu
->id()] = $menu
->label();
}
else {
$options[$menu
->id()] = $menu
->label();
}
}
return $options;
}
}