You are here

class OgMenuParentFormSelector in Organic Groups Menu (OG Menu) 8

Hierarchy

Expanded class hierarchy of OgMenuParentFormSelector

File

src/OgMenuParentFormSelector.php, line 6

Namespace

Drupal\og_menu
View 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

Namesort descending Modifiers Type Description Overrides
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
MenuParentFormSelector::$deprecatedProperties protected property
MenuParentFormSelector::$entityTypeManager protected property The entity type manager service.
MenuParentFormSelector::$menuLinkTree protected property The menu link tree service.
MenuParentFormSelector::getParentDepthLimit protected function Returns the maximum depth of the possible parents of the menu link.
MenuParentFormSelector::getParentSelectOptions public function Gets the options for a select element to choose a menu and parent. Overrides MenuParentFormSelectorInterface::getParentSelectOptions
MenuParentFormSelector::parentSelectOptionsTreeWalk protected function Iterates over all items in the tree to prepare the parents select options.
MenuParentFormSelector::__construct public function Constructs a \Drupal\Core\Menu\MenuParentFormSelector
OgMenuParentFormSelector::$is_og_menu protected property
OgMenuParentFormSelector::getMenuOptions protected function Gets a list of menu names for use as options. Overrides MenuParentFormSelector::getMenuOptions
OgMenuParentFormSelector::parentSelectElement public function Gets a form element to choose a menu and parent. Overrides MenuParentFormSelector::parentSelectElement
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.