class AccordionMenusBlock in Accordion Menus 8
Same name in this branch
- 8 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock
- 8 src/Plugin/Block/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Block\AccordionMenusBlock
Same name and namespace in other branches
- 8.4 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock
- 8.2 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock
- 8.3 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock
Provides block plugin definitions for accordion menus.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock implements ContainerDeriverInterface
Expanded class hierarchy of AccordionMenusBlock
See also
\Drupal\accordion_menus\Plugin\Block\AccordionMenusBlock
File
- src/
Plugin/ Derivative/ AccordionMenusBlock.php, line 20 - Contains \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock.
Namespace
Drupal\accordion_menus\Plugin\DerivativeView source
class AccordionMenusBlock 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) {
// Get menus from accordion configuration.
$accordion_menus = \Drupal::config('accordion_menus.settings')
->get('accordion_menus');
foreach ($this->menuStorage
->loadMultiple() as $menu => $entity) {
if (in_array($menu, $accordion_menus, true)) {
$this->derivatives[$menu] = $base_plugin_definition;
$this->derivatives[$menu]['admin_label'] = t('Accordion ') . $entity
->label();
$this->derivatives[$menu]['config_dependencies']['config'] = [
$entity
->getConfigDependencyName(),
];
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccordionMenusBlock:: |
protected | property | The menu storage. | |
AccordionMenusBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
AccordionMenusBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
AccordionMenusBlock:: |
public | function | Constructs new SystemMenuBlock. | |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |