class DomainMenuAccessMenuBlock in Domain Menu Access 8
Same name in this branch
- 8 src/Plugin/Derivative/DomainMenuAccessMenuBlock.php \Drupal\domain_menu_access\Plugin\Derivative\DomainMenuAccessMenuBlock
- 8 src/Plugin/Block/DomainMenuAccessMenuBlock.php \Drupal\domain_menu_access\Plugin\Block\DomainMenuAccessMenuBlock
Provides block plugin definitions for domain access menus.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\system\Plugin\Derivative\SystemMenuBlock implements ContainerDeriverInterface
- class \Drupal\domain_menu_access\Plugin\Derivative\DomainMenuAccessMenuBlock
- class \Drupal\system\Plugin\Derivative\SystemMenuBlock implements ContainerDeriverInterface
Expanded class hierarchy of DomainMenuAccessMenuBlock
See also
\Drupal\domain_access\Plugin\Block\DomainMenuAccessMenuBlock
File
- src/
Plugin/ Derivative/ DomainMenuAccessMenuBlock.php, line 15
Namespace
Drupal\domain_menu_access\Plugin\DerivativeView source
class DomainMenuAccessMenuBlock extends SystemMenuBlock {
/**
* Domain settings.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* Constructs new SystemMenuBlock.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $menu_storage
* The menu storage.
* @param \Drupal\Core\Config\ImmutableConfig $config
* Domain access settings.
*/
public function __construct(EntityStorageInterface $menu_storage, ImmutableConfig $config) {
parent::__construct($menu_storage);
$this->config = $config;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity.manager')
->getStorage('menu'), $container
->get('config.factory')
->get('domain_menu_access.settings'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$menu_enabled = $this->config
->get('menu_enabled');
foreach ($this->menuStorage
->loadMultiple() as $menu => $entity) {
if (in_array($menu, $menu_enabled)) {
$this->derivatives[$menu] = $base_plugin_definition;
$this->derivatives[$menu]['admin_label'] = $entity
->label();
$this->derivatives[$menu]['config_dependencies']['config'] = [
$entity
->getConfigDependencyName(),
];
}
}
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:: |
|
DomainMenuAccessMenuBlock:: |
protected | property | Domain settings. | |
DomainMenuAccessMenuBlock:: |
public static | function |
Creates a new class instance. Overrides SystemMenuBlock:: |
|
DomainMenuAccessMenuBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides SystemMenuBlock:: |
|
DomainMenuAccessMenuBlock:: |
public | function |
Constructs new SystemMenuBlock. Overrides SystemMenuBlock:: |
|
SystemMenuBlock:: |
protected | property | The menu storage. |