You are here

class MenuBlock in Menu Block 8

Same name in this branch
  1. 8 src/Plugin/Derivative/MenuBlock.php \Drupal\menu_block\Plugin\Derivative\MenuBlock
  2. 8 src/Plugin/Block/MenuBlock.php \Drupal\menu_block\Plugin\Block\MenuBlock

Provides an extended Menu block.

Plugin annotation


@Block(
  id = "menu_block",
  admin_label = @Translation("Menu block"),
  category = @Translation("Menus"),
  deriver = "Drupal\menu_block\Plugin\Derivative\MenuBlock",
  forms = {
    "settings_tray" = "\Drupal\system\Form\SystemMenuOffCanvasForm",
  },
)

Hierarchy

Expanded class hierarchy of MenuBlock

2 files declare their use of MenuBlock
MenuBlockTest.php in tests/src/Functional/MenuBlockTest.php
menu_block.install in ./menu_block.install
Install, update and uninstall functions for the Menu Block module.

File

src/Plugin/Block/MenuBlock.php, line 28

Namespace

Drupal\menu_block\Plugin\Block
View source
class MenuBlock extends SystemMenuBlock {

  /**
   * Constant definition options for block label type.
   */
  const LABEL_BLOCK = 'block';
  const LABEL_MENU = 'menu';
  const LABEL_ACTIVE_ITEM = 'active_item';
  const LABEL_PARENT = 'parent';
  const LABEL_ROOT = 'root';
  const LABEL_FIXED = 'fixed';

  /**
   * Entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The menu parent form selector service.
   *
   * @var \Drupal\Core\Menu\MenuParentFormSelectorInterface
   */
  protected $menuParentFormSelector;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
    $instance->menuParentFormSelector = $container
      ->get('menu.parent_form_selector');
    $instance->entityTypeManager = $container
      ->get('entity_type.manager');
    return $instance;
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    $config = $this->configuration;
    $defaults = $this
      ->defaultConfiguration();
    $form = parent::blockForm($form, $form_state);

    // If there exists a config value for Expand all menu links (expand), that
    // value should populate core's Expand all menu items checkbox
    // (expand_all_items).
    if (isset($config['expand'])) {
      $form['menu_levels']['expand_all_items']['#default_value'] = $config['expand'];
    }
    $form['advanced'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Advanced options'),
      '#open' => FALSE,
      '#process' => [
        [
          get_class(),
          'processMenuBlockFieldSets',
        ],
      ],
    ];
    $menu_name = $this
      ->getDerivativeId();
    $menus = Menu::loadMultiple([
      $menu_name,
    ]);
    $menus[$menu_name] = $menus[$menu_name]
      ->label();
    $form['advanced']['parent'] = $this->menuParentFormSelector
      ->parentSelectElement($config['parent'], '', $menus);
    $form['advanced']['parent'] += [
      '#title' => $this
        ->t('Fixed parent item'),
      '#description' => $this
        ->t('Alter the options in “Menu levels” to be relative to the fixed parent item. The block will only contain children of the selected menu link.'),
    ];
    $form['advanced']['label_type'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Use as title'),
      '#description' => $this
        ->t('Replace the block title with an item from the menu.'),
      '#options' => [
        self::LABEL_BLOCK => $this
          ->t('Block title'),
        self::LABEL_MENU => $this
          ->t('Menu title'),
        self::LABEL_FIXED => $this
          ->t("Fixed parent item's title"),
        self::LABEL_ACTIVE_ITEM => $this
          ->t("Active item's title"),
        self::LABEL_PARENT => $this
          ->t("Active trail's parent title"),
        self::LABEL_ROOT => $this
          ->t("Active trail's root title"),
      ],
      '#default_value' => $config['label_type'],
      '#states' => [
        'visible' => [
          ':input[name="settings[label_display]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
    $form['advanced']['label_link'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Link the title?'),
      '#default_value' => $config['label_link'],
      '#states' => [
        'visible' => [
          ':input[name="settings[label_display]"]' => [
            'checked' => TRUE,
          ],
          ':input[name="settings[label_type]"]' => [
            [
              'value' => self::LABEL_ACTIVE_ITEM,
            ],
            [
              'value' => self::LABEL_PARENT,
            ],
            [
              'value' => self::LABEL_ROOT,
            ],
            [
              'value' => self::LABEL_FIXED,
            ],
          ],
        ],
      ],
    ];
    $form['style'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('HTML and style options'),
      '#open' => FALSE,
      '#process' => [
        [
          get_class(),
          'processMenuBlockFieldSets',
        ],
      ],
    ];
    $form['advanced']['follow'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('<strong>Make the initial visibility level follow the active menu item.</strong>'),
      '#default_value' => $config['follow'],
      '#description' => $this
        ->t('If the active menu item is deeper than the initial visibility level set above, the initial visibility level will be relative to the active menu item. Otherwise, the initial visibility level of the tree will remain fixed.'),
    ];
    $form['advanced']['follow_parent'] = [
      '#type' => 'radios',
      '#title' => $this
        ->t('Initial visibility level will be'),
      '#description' => $this
        ->t('When following the active menu item, select whether the initial visibility level should be set to the active menu item, or its children.'),
      '#default_value' => $config['follow_parent'],
      '#options' => [
        'active' => $this
          ->t('Active menu item'),
        'child' => $this
          ->t('Children of active menu item'),
      ],
      '#states' => [
        'visible' => [
          ':input[name="settings[follow]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
    $form['style']['suggestion'] = [
      '#type' => 'machine_name',
      '#title' => $this
        ->t('Theme hook suggestion'),
      '#default_value' => $config['suggestion'],
      '#field_prefix' => '<code>menu__</code>',
      '#description' => $this
        ->t('A theme hook suggestion can be used to override the default HTML and CSS classes for menus found in <code>menu.html.twig</code>.'),
      '#machine_name' => [
        'error' => $this
          ->t('The theme hook suggestion must contain only lowercase letters, numbers, and underscores.'),
        'exists' => [
          $this,
          'suggestionExists',
        ],
      ],
    ];

    // Open the details field sets if their config is not set to defaults.
    foreach ([
      'menu_levels',
      'advanced',
      'style',
    ] as $fieldSet) {
      foreach (array_keys($form[$fieldSet]) as $field) {
        if (isset($defaults[$field]) && $defaults[$field] !== $config[$field]) {
          $form[$fieldSet]['#open'] = TRUE;
        }
      }
    }
    return $form;
  }

  /**
   * Form API callback: Processes the elements in field sets.
   *
   * Adjusts the #parents of field sets to save its children at the top level.
   */
  public static function processMenuBlockFieldSets(&$element, FormStateInterface $form_state, &$complete_form) {
    array_pop($element['#parents']);
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->configuration['follow'] = $form_state
      ->getValue('follow');
    $this->configuration['follow_parent'] = $form_state
      ->getValue('follow_parent');
    $this->configuration['level'] = $form_state
      ->getValue('level');
    $this->configuration['depth'] = $form_state
      ->getValue('depth');
    $this->configuration['expand_all_items'] = (bool) $form_state
      ->getValue('expand_all_items');

    // On save, the core config property (expand_all_items) gets updated, and
    // the contrib config property value (expand) is deleted/removed altogether.
    if (isset($this->configuration['expand'])) {
      unset($this->configuration['expand']);
    }
    $this->configuration['parent'] = $form_state
      ->getValue('parent');
    $this->configuration['suggestion'] = $form_state
      ->getValue('suggestion');
    $this->configuration['label_type'] = $form_state
      ->getValue('label_type');
    $this->configuration['label_link'] = $form_state
      ->getValue('label_link');
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    $menu_name = $this
      ->getDerivativeId();
    $parameters = $this->menuTree
      ->getCurrentRouteMenuTreeParameters($menu_name);

    // Adjust the menu tree parameters based on the block's configuration.
    $level = $this->configuration['level'];
    $depth = $this->configuration['depth'];

    // For blocks placed in Layout Builder or similar, check for the deprecated
    // 'expand' config property in case the menu block's configuration has not
    // yet been updated.
    $expand_all_items = $this->configuration['expand'] ?? $this->configuration['expand_all_items'];
    $parent = $this->configuration['parent'];
    $follow = $this->configuration['follow'];
    $follow_parent = $this->configuration['follow_parent'];
    $following = FALSE;
    $parameters
      ->setMinDepth($level);

    // If we're following the active trail and the active trail is deeper than
    // the initial starting level, we update the level to match the active menu
    // item's level in the menu.
    if ($follow && count($parameters->activeTrail) > $level) {
      $level = count($parameters->activeTrail);
      $following = TRUE;
    }

    // When the depth is configured to zero, there is no depth limit. When depth
    // is non-zero, it indicates the number of levels that must be displayed.
    // Hence this is a relative depth that we must convert to an actual
    // (absolute) depth, that may never exceed the maximum depth.
    if ($depth > 0) {
      $parameters
        ->setMaxDepth(min($level + $depth - 1, $this->menuTree
        ->maxDepth()));
    }

    // If we're currently following an active menu item, or for menu blocks with
    // start level greater than 1, only show menu items from the current active
    // trail. Adjust the root according to the current position in the menu in
    // order to determine if we can show the subtree. If we're not following an
    // active trail and using a fixed parent item, we'll skip this step.
    $fixed_parent_menu_link_id = str_replace($menu_name . ':', '', $parent);
    if ($following || $level > 1 && !$fixed_parent_menu_link_id) {
      if (count($parameters->activeTrail) >= $level) {

        // Active trail array is child-first. Reverse it, and pull the new menu
        // root based on the parent of the configured start level.
        $menu_trail_ids = array_reverse(array_values($parameters->activeTrail));
        $offset = $following && $follow_parent == 'active' ? 2 : 1;
        $menu_root = $menu_trail_ids[$level - $offset];
        $parameters
          ->setRoot($menu_root)
          ->setMinDepth(1);
        if ($depth > 0) {
          $parameters
            ->setMaxDepth(min($depth, $this->menuTree
            ->maxDepth()));
        }
      }
      else {
        return [];
      }
    }

    // If expandedParents is empty, the whole menu tree is built.
    if ($expand_all_items) {
      $parameters->expandedParents = [];
    }

    // When a fixed parent item is set, root the menu tree at the given ID.
    if ($fixed_parent_menu_link_id) {

      // Clone the parameters so we can fall back to using them if we're
      // following the active menu item and the current page is part of the
      // active menu trail.
      $fixed_parameters = clone $parameters;
      $fixed_parameters
        ->setRoot($fixed_parent_menu_link_id);
      $tree = $this->menuTree
        ->load($menu_name, $fixed_parameters);

      // Check if the tree contains links.
      if (empty($tree)) {

        // If the starting level is 1, we always want the child links to appear,
        // but the requested tree may be empty if the tree does not contain the
        // active trail. We're accessing the configuration directly since the
        // $level variable may have changed by this point.
        if ($this->configuration['level'] === 1 || $this->configuration['level'] === '1') {

          // Change the request to expand all children and limit the depth to
          // the immediate children of the root.
          $fixed_parameters->expandedParents = [];
          $fixed_parameters
            ->setMinDepth(1);
          $fixed_parameters
            ->setMaxDepth(1);

          // Re-load the tree.
          $tree = $this->menuTree
            ->load($menu_name, $fixed_parameters);
        }
      }
      elseif ($following) {

        // If we're following the active menu item, and the tree isn't empty
        // (which indicates we're currently in the active trail), we unset
        // the tree we made and just let the active menu parameters from before
        // do their thing.
        unset($tree);
      }
    }

    // Load the tree if we haven't already.
    if (!isset($tree)) {
      $tree = $this->menuTree
        ->load($menu_name, $parameters);
    }
    $manipulators = [
      [
        'callable' => 'menu.default_tree_manipulators:checkAccess',
      ],
      [
        'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
      ],
    ];
    $tree = $this->menuTree
      ->transform($tree, $manipulators);
    $build = $this->menuTree
      ->build($tree);
    $label = $this
      ->getBlockLabel() ?: $this
      ->label();

    // Set the block's #title (label) to the dynamic value.
    $build['#title'] = [
      '#markup' => $label,
    ];
    if (!empty($build['#theme'])) {

      // Add the configuration for use in menu_block_theme_suggestions_menu().
      $build['#menu_block_configuration'] = $this->configuration;

      // Set the generated label into the configuration array so it is
      // propagated to the theme preprocessor and template(s) as needed.
      $build['#menu_block_configuration']['label'] = $label;

      // Remove the menu name-based suggestion so we can control its precedence
      // better in menu_block_theme_suggestions_menu().
      $build['#theme'] = 'menu';
    }
    $build['#contextual_links']['menu'] = [
      'route_parameters' => [
        'menu' => $menu_name,
      ],
    ];
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function blockAccess(AccountInterface $account) {
    $build = $this
      ->build();
    if (empty($build['#items'])) {
      return AccessResult::forbidden();
    }
    return parent::blockAccess($account);
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'follow' => 0,
      'follow_parent' => 'child',
      'level' => 1,
      'depth' => 0,
      'expand_all_items' => FALSE,
      'parent' => $this
        ->getDerivativeId() . ':',
      'suggestion' => strtr($this
        ->getDerivativeId(), '-', '_'),
      'label_type' => self::LABEL_BLOCK,
      'label_link' => FALSE,
    ];
  }

  /**
   * Checks for an existing theme hook suggestion.
   *
   * @return bool
   *   Returns FALSE because there is no need of validation by unique value.
   */
  public function suggestionExists() {
    return FALSE;
  }

  /**
   * Gets the configured block label.
   *
   * @return string
   *   The configured label.
   */
  public function getBlockLabel() {
    switch ($this->configuration['label_type']) {
      case self::LABEL_MENU:
        return $this
          ->getMenuTitle();
      case self::LABEL_ACTIVE_ITEM:
        return $this
          ->getActiveItemTitle();
      case self::LABEL_PARENT:
        return $this
          ->getActiveTrailParentTitle();
      case self::LABEL_ROOT:
        return $this
          ->getActiveTrailRootTitle();
      case self::LABEL_FIXED:
        return $this
          ->getFixedMenuItemTitle();
      default:
        return $this
          ->label();
    }
  }

  /**
   * Gets the label of the configured menu.
   *
   * @return string|null
   *   Menu label or NULL if no menu exists.
   */
  protected function getMenuTitle() {
    try {
      $menu = $this->entityTypeManager
        ->getStorage('menu')
        ->load($this
        ->getDerivativeId());
    } catch (\Exception $e) {
      return NULL;
    }
    return $menu ? $menu
      ->label() : NULL;
  }

  /**
   * Gets the title of a fixed parent item.
   *
   * @return string|null
   *   Title of the configured (fixed) parent item, or NULL if there is none.
   */
  protected function getFixedMenuItemTitle() {
    $parent = $this->configuration['parent'];
    if ($parent) {
      $fixed_menu_link_id = str_replace($this
        ->getDerivativeId() . ':', '', $parent);
      return $this
        ->getLinkTitleFromLink($fixed_menu_link_id);
    }
  }

  /**
   * Gets the active menu item's title.
   *
   * @return string|null
   *   Currently active menu item title or NULL if there's nothing active.
   */
  protected function getActiveItemTitle() {

    /** @var array $active_trail_ids */
    $active_trail_ids = $this
      ->getDerivativeActiveTrailIds();
    if ($active_trail_ids) {
      return $this
        ->getLinkTitleFromLink(reset($active_trail_ids));
    }
  }

  /**
   * Gets the title of the parent of the active menu item.
   *
   * @return string|null
   *   The title of the parent of the active menu item, the title of the active
   *   item if it has no parent, or NULL if there's no active menu item.
   */
  protected function getActiveTrailParentTitle() {

    /** @var array $active_trail_ids */
    $active_trail_ids = $this
      ->getDerivativeActiveTrailIds();
    if ($active_trail_ids) {
      if (count($active_trail_ids) === 1) {
        return $this
          ->getActiveItemTitle();
      }
      return $this
        ->getLinkTitleFromLink(next($active_trail_ids));
    }
  }

  /**
   * Gets the current menu item's root menu item title.
   *
   * @return string|null
   *   The root menu item title or NULL if there's no active item.
   */
  protected function getActiveTrailRootTitle() {

    /** @var array $active_trail_ids */
    $active_trail_ids = $this
      ->getDerivativeActiveTrailIds();
    if ($active_trail_ids) {
      return $this
        ->getLinkTitleFromLink(end($active_trail_ids));
    }
  }

  /**
   * Gets an array of the active trail menu link items.
   *
   * @return array
   *   The active trail menu item IDs.
   */
  protected function getDerivativeActiveTrailIds() {
    $menu_id = $this
      ->getDerivativeId();
    return array_filter($this->menuActiveTrail
      ->getActiveTrailIds($menu_id));
  }

  /**
   * Gets the title of a given menu item ID.
   *
   * @param string $link_id
   *   The menu item ID.
   *
   * @return string|null
   *   The menu item title or NULL if the given menu item can't be found.
   */
  protected function getLinkTitleFromLink($link_id) {
    $parameters = new MenuTreeParameters();
    $menu = $this->menuTree
      ->load($this
      ->getDerivativeId(), $parameters);
    $link = $this
      ->findLinkInTree($menu, $link_id);
    if ($link) {
      if ($this->configuration['label_link']) {
        $block_link = Link::fromTextAndUrl($link->link
          ->getTitle(), $link->link
          ->getUrlObject())
          ->toString();
        return Markup::create($block_link);
      }
      return $link->link
        ->getTitle();
    }
  }

  /**
   * Gets the menu link item from the menu tree.
   *
   * @param array $menu_tree
   *   Associative array containing the menu link tree data.
   * @param string $link_id
   *   Menu link id to find.
   *
   * @return \Drupal\Core\Menu\MenuLinkTreeElement|null
   *   The link element from the given menu tree or NULL if it can't be found.
   */
  protected function findLinkInTree(array $menu_tree, $link_id) {
    if (isset($menu_tree[$link_id])) {
      return $menu_tree[$link_id];
    }

    /** @var \Drupal\Core\Menu\MenuLinkTreeElement $link */
    foreach ($menu_tree as $link) {
      $link = $this
        ->findLinkInTree($link->subtree, $link_id);
      if ($link) {
        return $link;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlockPluginInterface::BLOCK_LABEL_VISIBLE constant Indicates the block label (title) should be displayed to end users.
BlockPluginTrait::$transliteration protected property The transliteration service.
BlockPluginTrait::access public function
BlockPluginTrait::baseConfigurationDefaults protected function Returns generic default configuration for block plugins.
BlockPluginTrait::blockValidate public function 3
BlockPluginTrait::buildConfigurationForm public function Creates a generic configuration form for all block types. Individual block plugins can add elements to this form by overriding BlockBase::blockForm(). Most block plugins should not override this method unless they need to alter the generic form elements. 2
BlockPluginTrait::calculateDependencies public function
BlockPluginTrait::getConfiguration public function 1
BlockPluginTrait::getMachineNameSuggestion public function 1
BlockPluginTrait::getPreviewFallbackString public function 3
BlockPluginTrait::label public function
BlockPluginTrait::setConfiguration public function
BlockPluginTrait::setConfigurationValue public function
BlockPluginTrait::setTransliteration public function Sets the transliteration service.
BlockPluginTrait::submitConfigurationForm public function Most block plugins should not override this method. To add submission handling for a specific block type, override BlockBase::blockSubmit().
BlockPluginTrait::transliteration protected function Wraps the transliteration service.
BlockPluginTrait::validateConfigurationForm public function Most block plugins should not override this method. To add validation for a specific block type, override BlockBase::blockValidate(). 1
ContextAwarePluginAssignmentTrait::addContextAssignmentElement protected function Builds a form element for assigning a context to a given slot.
ContextAwarePluginAssignmentTrait::contextHandler protected function Wraps the context handler.
ContextAwarePluginBase::$context protected property The data objects representing the context of this plugin.
ContextAwarePluginBase::$contexts Deprecated private property Data objects representing the contexts passed in the plugin configuration.
ContextAwarePluginBase::createContextFromConfiguration protected function Overrides ContextAwarePluginBase::createContextFromConfiguration
ContextAwarePluginBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge 7
ContextAwarePluginBase::getContext public function This code is identical to the Component in order to pick up a different Context class. Overrides ContextAwarePluginBase::getContext
ContextAwarePluginBase::getContextDefinition public function Overrides ContextAwarePluginBase::getContextDefinition
ContextAwarePluginBase::getContextDefinitions public function Overrides ContextAwarePluginBase::getContextDefinitions
ContextAwarePluginBase::getContextMapping public function Gets a mapping of the expected assignment names to their context names. Overrides ContextAwarePluginInterface::getContextMapping
ContextAwarePluginBase::getContexts public function Gets the defined contexts. Overrides ContextAwarePluginInterface::getContexts
ContextAwarePluginBase::getContextValue public function Gets the value for a defined context. Overrides ContextAwarePluginInterface::getContextValue
ContextAwarePluginBase::getContextValues public function Gets the values for all defined contexts. Overrides ContextAwarePluginInterface::getContextValues
ContextAwarePluginBase::setContext public function Set a context on this plugin. Overrides ContextAwarePluginBase::setContext
ContextAwarePluginBase::setContextMapping public function Sets a mapping of the expected assignment names to their context names. Overrides ContextAwarePluginInterface::setContextMapping
ContextAwarePluginBase::setContextValue public function Sets the value for a defined context. Overrides ContextAwarePluginBase::setContextValue
ContextAwarePluginBase::validateContexts public function Validates the set values for the defined contexts. Overrides ContextAwarePluginInterface::validateContexts
ContextAwarePluginBase::__get public function Implements magic __get() method.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MenuBlock::$entityTypeManager protected property Entity type manager.
MenuBlock::$menuParentFormSelector protected property The menu parent form selector service.
MenuBlock::blockAccess public function Indicates whether the block should be shown. Overrides BlockPluginTrait::blockAccess
MenuBlock::blockForm public function Overrides SystemMenuBlock::blockForm
MenuBlock::blockSubmit public function Overrides SystemMenuBlock::blockSubmit
MenuBlock::build public function Builds and returns the renderable array for this block plugin. Overrides SystemMenuBlock::build
MenuBlock::create public static function Creates an instance of the plugin. Overrides SystemMenuBlock::create
MenuBlock::defaultConfiguration public function Overrides SystemMenuBlock::defaultConfiguration
MenuBlock::findLinkInTree protected function Gets the menu link item from the menu tree.
MenuBlock::getActiveItemTitle protected function Gets the active menu item's title.
MenuBlock::getActiveTrailParentTitle protected function Gets the title of the parent of the active menu item.
MenuBlock::getActiveTrailRootTitle protected function Gets the current menu item's root menu item title.
MenuBlock::getBlockLabel public function Gets the configured block label.
MenuBlock::getDerivativeActiveTrailIds protected function Gets an array of the active trail menu link items.
MenuBlock::getFixedMenuItemTitle protected function Gets the title of a fixed parent item.
MenuBlock::getLinkTitleFromLink protected function Gets the title of a given menu item ID.
MenuBlock::getMenuTitle protected function Gets the label of the configured menu.
MenuBlock::LABEL_ACTIVE_ITEM constant
MenuBlock::LABEL_BLOCK constant Constant definition options for block label type.
MenuBlock::LABEL_FIXED constant
MenuBlock::LABEL_MENU constant
MenuBlock::LABEL_PARENT constant
MenuBlock::LABEL_ROOT constant
MenuBlock::processMenuBlockFieldSets public static function Form API callback: Processes the elements in field sets.
MenuBlock::suggestionExists public function Checks for an existing theme hook suggestion.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginWithFormsTrait::getFormClass public function
PluginWithFormsTrait::hasFormClass public function
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.
SystemMenuBlock::$menuActiveTrail protected property The active menu trail service.
SystemMenuBlock::$menuTree protected property The menu link tree service.
SystemMenuBlock::getCacheContexts public function The cache contexts associated with this object. Overrides ContextAwarePluginBase::getCacheContexts
SystemMenuBlock::getCacheTags public function The cache tags associated with this object. Overrides ContextAwarePluginBase::getCacheTags
SystemMenuBlock::processMenuLevelParents public static function Form API callback: Processes the menu_levels field element.
SystemMenuBlock::__construct public function Constructs a new SystemMenuBlock. Overrides BlockPluginTrait::__construct
TypedDataTrait::$typedDataManager protected property The typed data manager used for creating the data types.
TypedDataTrait::getTypedDataManager public function Gets the typed data manager. 2
TypedDataTrait::setTypedDataManager public function Sets the typed data manager. 2