You are here

EntitySubmenuBlock.php in Entity Submenu Block 8

File

src/Plugin/Derivative/EntitySubmenuBlock.php
View source
<?php

namespace Drupal\entity_submenu_block\Plugin\Derivative;

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\system\Plugin\Derivative\SystemMenuBlock;

/**
 * Provides block plugin definitions for custom menus.
 *
 * @see \Drupal\system\Plugin\Block\SystemMenuBlock
 */
class EntitySubmenuBlock extends SystemMenuBlock {
  use StringTranslationTrait;

  /**
   * {@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
        ->t('Entity Submenu Block') . ')';
      $this->derivatives[$menu]['config_dependencies']['config'] = array(
        $entity
          ->getConfigDependencyName(),
      );
    }
    return $this->derivatives;
  }

}

Classes

Namesort descending Description
EntitySubmenuBlock Provides block plugin definitions for custom menus.