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 block plugin definitions for custom menus.

Hierarchy

Expanded class hierarchy of MenuBlock

See also

\Drupal\system\Plugin\Block\SystemMenuBlock

File

src/Plugin/Derivative/MenuBlock.php, line 12

Namespace

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

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->menuStorage
      ->loadMultiple() as $menu => $entity) {
      $this->derivatives[$menu] = $base_plugin_definition;
      $this->derivatives[$menu]['admin_label'] = $entity
        ->label();
      $this->derivatives[$menu]['config_dependencies']['config'] = [
        $entity
          ->getConfigDependencyName(),
      ];
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
MenuBlock::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides SystemMenuBlock::getDerivativeDefinitions
SystemMenuBlock::$menuStorage protected property The menu storage.
SystemMenuBlock::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
SystemMenuBlock::__construct public function Constructs new SystemMenuBlock.