SystemMenuBlock.php
Same filename in this branch
Same filename in other branches
- 9 core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php
- 9 core/modules/system/src/Plugin/Block/SystemMenuBlock.php
- 10 core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php
- 10 core/modules/system/src/Plugin/Block/SystemMenuBlock.php
- 11.x core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php
- 11.x core/modules/system/src/Plugin/Block/SystemMenuBlock.php
Namespace
Drupal\system\Plugin\DerivativeFile
-
core/
modules/ system/ src/ Plugin/ Derivative/ SystemMenuBlock.php
View source
<?php
namespace Drupal\system\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides block plugin definitions for custom menus.
*
* @see \Drupal\system\Plugin\Block\SystemMenuBlock
*/
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_type.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'] = [
$entity->getConfigDependencyName(),
];
}
return $this->derivatives;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
SystemMenuBlock | Provides block plugin definitions for custom menus. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.