class TBMegaMenuBlock in The Better Mega Menu 8
Same name in this branch
- 8 src/Plugin/Derivative/TBMegaMenuBlock.php \Drupal\tb_megamenu\Plugin\Derivative\TBMegaMenuBlock
- 8 src/Plugin/Block/TBMegaMenuBlock.php \Drupal\tb_megamenu\Plugin\Block\TBMegaMenuBlock
Same name and namespace in other branches
- 2.x src/Plugin/Derivative/TBMegaMenuBlock.php \Drupal\tb_megamenu\Plugin\Derivative\TBMegaMenuBlock
Provides blocks which belong to TB Mega Menu.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\tb_megamenu\Plugin\Derivative\TBMegaMenuBlock implements ContainerDeriverInterface
Expanded class hierarchy of TBMegaMenuBlock
File
- src/
Plugin/ Derivative/ TBMegaMenuBlock.php, line 15
Namespace
Drupal\tb_megamenu\Plugin\DerivativeView source
class TBMegaMenuBlock extends DeriverBase implements ContainerDeriverInterface {
/**
* Config factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Entity type manager.
*
* @var \Drupal\core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* TBMegaMenuBlock constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* Config factory interface.
*/
public function __construct(ConfigFactoryInterface $configFactory, EntityTypeManagerInterface $entityTypeManager) {
$this->configFactory = $configFactory;
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('config.factory'), $container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$menus = $this->entityTypeManager
->getStorage('menu')
->loadMultiple();
asort($menus);
foreach ($this->configFactory
->listAll('tb_megamenu.menu_config.') as $index_id) {
$info = $this->configFactory
->get($index_id);
$menu = $info
->get('menu');
if (isset($menus[$menu])) {
$this->derivatives[$menu] = $base_plugin_definition;
$this->derivatives[$menu]['admin_label'] = $menus[$menu]
->label();
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
TBMegaMenuBlock:: |
protected | property | Config factory service. | |
TBMegaMenuBlock:: |
protected | property | Entity type manager. | |
TBMegaMenuBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
TBMegaMenuBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
TBMegaMenuBlock:: |
public | function | TBMegaMenuBlock constructor. |