public function SystemMenuBlock::getDerivativeDefinitions

Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().

Overrides DerivativeInterface::getDerivativeDefinitions

1 call to SystemMenuBlock::getDerivativeDefinitions()
1 method overrides SystemMenuBlock::getDerivativeDefinitions()

File

drupal/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php, line 40
Contains \Drupal\system\Plugin\Derivative\SystemMenuBlock.

Class

SystemMenuBlock
Provides block plugin definitions for system menus.

Namespace

Drupal\system\Plugin\Derivative

Code

public function getDerivativeDefinitions(array $base_plugin_definition) {

  // Provide a block plugin definition for each system menu.
  foreach (menu_list_system_menus() as $menu => $name) {

    // The block deltas need to be prefixed with 'menu-', since the 'main'
    // menu would otherwise clash with the 'main' page content block.
    $menu_key = 'menu-' . $menu;
    $this->derivatives[$menu_key] = $base_plugin_definition;
    $this->derivatives[$menu_key]['delta'] = $menu_key;

    // It is possible that users changed the menu label. Fall back on the
    // built-in menu label if the entity was not found.
    $entity = entity_load('menu', $menu);
    $this->derivatives[$menu_key]['admin_label'] = !empty($entity) ? $entity
      ->label() : $name;
    $this->derivatives[$menu_key]['cache'] = DRUPAL_NO_CACHE;
  }
  return $this->derivatives;
}