Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 13 |
| SystemMenuBlock | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 13 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| getDerivativeDefinitions | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 7 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\system\Plugin\Derivative\SystemMenuBlock. | |
| */ | |
| 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.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; | |
| } | |
| } |