1. 8.2.x core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php SystemMenuBlock
  2. 8.2.x core/modules/system/src/Plugin/Block/SystemMenuBlock.php SystemMenuBlock
  3. 8.0.x core/modules/system/src/Plugin/Block/SystemMenuBlock.php SystemMenuBlock
  4. 8.0.x core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php SystemMenuBlock
  5. 8.1.x core/modules/system/src/Plugin/Block/SystemMenuBlock.php SystemMenuBlock
  6. 8.1.x core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php SystemMenuBlock
  7. 8.3.x core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php SystemMenuBlock
  8. 8.3.x core/modules/system/src/Plugin/Block/SystemMenuBlock.php SystemMenuBlock

Provides block plugin definitions for custom menus.

Hierarchy

Expanded class hierarchy of SystemMenuBlock

See also

\Drupal\system\Plugin\Block\SystemMenuBlock

File

core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php, line 15

Namespace

Drupal\system\Plugin\Derivative
View source
class SystemMenuBlock extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The menu storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $menuStorage;

  /**
   * Constructs new SystemMenuBlock.
   *
   * @param \Drupal\Core\Entity\EntityStorageInterface $menu_storage
   *   The menu storage.
   */
  public function __construct(EntityStorageInterface $menu_storage) {
    $this->menuStorage = $menu_storage;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static(
    $container->get('entity.manager')->getStorage('menu')
    );
  }

  /**
   * {@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'] = array($entity->getConfigDependencyName());
    }
    return $this->derivatives;
  }

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
DeriverBase::$derivatives protected property List of derivative definitions.
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
SystemMenuBlock::$menuStorage protected property The menu storage.
SystemMenuBlock::create public static function Overrides ContainerDeriverInterface::create
SystemMenuBlock::getDerivativeDefinitions public function Overrides DeriverBase::getDerivativeDefinitions
SystemMenuBlock::__construct public function Constructs new SystemMenuBlock.