class OgMenuParentFormSelector in Organic Groups Menu (OG Menu) 8
Hierarchy
- class \Drupal\Core\Menu\MenuParentFormSelector implements MenuParentFormSelectorInterface uses DeprecatedServicePropertyTrait, StringTranslationTrait
- class \Drupal\og_menu\OgMenuParentFormSelector
Expanded class hierarchy of OgMenuParentFormSelector
File
- src/
OgMenuParentFormSelector.php, line 6
Namespace
Drupal\og_menuView source
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';
}
/**
* @todo Here we'll need to do some access checks to see if which menus
* belong to the og.
*/
$menus = $this->entityTypeManager
->getStorage($entity_type)
->loadMultiple($menu_names);
$options = array();
/** @var \Drupal\system\MenuInterface[] $menus */
foreach ($menus as $menu) {
if ($this->is_og_menu) {
$options['ogmenu-' . $menu
->id()] = $menu
->label();
}
else {
$options[$menu
->id()] = $menu
->label();
}
}
return $options;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeprecatedServicePropertyTrait:: |
public | function | Allows to access deprecated/removed properties. | |
MenuParentFormSelector:: |
protected | property | ||
MenuParentFormSelector:: |
protected | property | The entity type manager service. | |
MenuParentFormSelector:: |
protected | property | The menu link tree service. | |
MenuParentFormSelector:: |
protected | function | Returns the maximum depth of the possible parents of the menu link. | |
MenuParentFormSelector:: |
public | function |
Gets the options for a select element to choose a menu and parent. Overrides MenuParentFormSelectorInterface:: |
|
MenuParentFormSelector:: |
protected | function | Iterates over all items in the tree to prepare the parents select options. | |
MenuParentFormSelector:: |
public | function | Constructs a \Drupal\Core\Menu\MenuParentFormSelector | |
OgMenuParentFormSelector:: |
protected | property | ||
OgMenuParentFormSelector:: |
protected | function |
Gets a list of menu names for use as options. Overrides MenuParentFormSelector:: |
|
OgMenuParentFormSelector:: |
public | function |
Gets a form element to choose a menu and parent. Overrides MenuParentFormSelector:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |