3 namespace Drupal\system\Plugin\Derivative;
5 use Drupal\Component\Plugin\Derivative\DeriverBase;
6 use Drupal\Core\Entity\EntityStorageInterface;
7 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Provides block plugin definitions for custom menus.
13 * @see \Drupal\system\Plugin\Block\SystemMenuBlock
15 class SystemMenuBlock extends DeriverBase implements ContainerDeriverInterface {
20 * @var \Drupal\Core\Entity\EntityStorageInterface
22 protected $menuStorage;
25 * Constructs new SystemMenuBlock.
27 * @param \Drupal\Core\Entity\EntityStorageInterface $menu_storage
30 public function __construct(EntityStorageInterface $menu_storage) {
31 $this->menuStorage = $menu_storage;
37 public static function create(ContainerInterface $container, $base_plugin_id) {
39 $container->get('entity.manager')->getStorage('menu')
46 public function getDerivativeDefinitions($base_plugin_definition) {
47 foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
48 $this->derivatives[$menu] = $base_plugin_definition;
49 $this->derivatives[$menu]['admin_label'] = $entity->label();
50 $this->derivatives[$menu]['config_dependencies']['config'] = [$entity->getConfigDependencyName()];
52 return $this->derivatives;