class OgMenuBlock in Organic Groups Menu (OG Menu) 8
Same name in this branch
- 8 src/Plugin/Derivative/OgMenuBlock.php \Drupal\og_menu\Plugin\Derivative\OgMenuBlock
- 8 src/Plugin/Block/OgMenuBlock.php \Drupal\og_menu\Plugin\Block\OgMenuBlock
Provides block plugin definitions for custom menus.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\og_menu\Plugin\Derivative\OgMenuBlock implements ContainerDeriverInterface
Expanded class hierarchy of OgMenuBlock
See also
\Drupal\system\Plugin\Block\SystemMenuBlock
File
- src/
Plugin/ Derivative/ OgMenuBlock.php, line 21 - Contains \Drupal\system\Plugin\Derivative\SystemMenuBlock.
Namespace
Drupal\og_menu\Plugin\DerivativeView source
class OgMenuBlock 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('ogmenu'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
/**
* @var string $menu
* @var \Drupal\og_menu\Entity\OgMenuInstance $entity
*/
foreach ($this->menuStorage
->loadMultiple() as $menu => $entity) {
if (!Og::isGroupContent('ogmenu_instance', $entity
->id())) {
continue;
}
$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;
}
}
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:: |
|
OgMenuBlock:: |
protected | property | The menu storage. | |
OgMenuBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
OgMenuBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
OgMenuBlock:: |
public | function | Constructs new SystemMenuBlock. |