class SimpleBlock in Simple Block 8
Same name in this branch
- 8 src/Entity/SimpleBlock.php \Drupal\simple_block\Entity\SimpleBlock
- 8 src/Plugin/Derivative/SimpleBlock.php \Drupal\simple_block\Plugin\Derivative\SimpleBlock
Retrieves block plugin definitions for all custom config blocks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\simple_block\Plugin\Derivative\SimpleBlock implements ContainerDeriverInterface
Expanded class hierarchy of SimpleBlock
File
- src/
Plugin/ Derivative/ SimpleBlock.php, line 13
Namespace
Drupal\simple_block\Plugin\DerivativeView source
class SimpleBlock extends DeriverBase implements ContainerDeriverInterface {
/**
* The custom config block storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $blockConfigStorage;
/**
* Constructs a BlockContent object.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $block_content_storage
* The custom block storage.
*/
public function __construct(EntityStorageInterface $block_content_storage) {
$this->blockConfigStorage = $block_content_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
$entity_type_manager = $container
->get('entity_type.manager');
return new static($entity_type_manager
->getStorage('simple_block'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
/** @var \Drupal\simple_block\Entity\SimpleBlock $simple_block */
foreach ($this->blockConfigStorage
->loadMultiple() as $simple_block) {
$this->derivatives[$simple_block
->id()] = $base_plugin_definition;
$this->derivatives[$simple_block
->id()]['admin_label'] = $simple_block
->label();
$this->derivatives[$simple_block
->id()]['config_dependencies'][$simple_block
->getConfigDependencyKey()] = [
$simple_block
->getConfigDependencyName(),
];
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
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:: |
|
SimpleBlock:: |
protected | property | The custom config block storage. | |
SimpleBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
SimpleBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
SimpleBlock:: |
public | function | Constructs a BlockContent object. |