MenuBlock.php 792 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php

/**
 * @file
 * Contains \Drupal\menu\Plugin\Derivative\MenuBlock.
 */

namespace Drupal\menu\Plugin\Derivative;

use Drupal\system\Plugin\Derivative\SystemMenuBlock;

/**
 * Provides block plugin definitions for custom menus.
 *
 * @see \Drupal\menu\Plugin\block\block\MenuBlock
 */
class MenuBlock extends SystemMenuBlock {
  /**
19
   * {@inheritdoc}
20 21 22 23 24
   */
  public function getDerivativeDefinitions(array $base_plugin_definition) {
    // Provide block plugin definitions for all user-defined (custom) menus.
    foreach (menu_get_menus(FALSE) as $menu => $name) {
      $this->derivatives[$menu] = $base_plugin_definition;
25
      $this->derivatives[$menu]['admin_label'] = $name;
26 27 28 29 30 31
      $this->derivatives[$menu]['cache'] = DRUPAL_NO_CACHE;
    }
    return $this->derivatives;
  }

}