class TagPluginDeriver in Extensible BBCode 4.0.x
Same name and namespace in other branches
- 8.3 src/Plugin/Derivative/TagPluginDeriver.php \Drupal\xbbcode\Plugin\Derivative\TagPluginDeriver
Provide a tag plugin for each XBBCodeCustom entity.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\xbbcode\Plugin\Derivative\TagPluginDeriver implements ContainerDeriverInterface
Expanded class hierarchy of TagPluginDeriver
File
- src/
Plugin/ Derivative/ TagPluginDeriver.php, line 14
Namespace
Drupal\xbbcode\Plugin\DerivativeView source
class TagPluginDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* Entity storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* Constructs a Deriver.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage.
*/
public function __construct(EntityStorageInterface $storage) {
$this->storage = $storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager')
->getStorage('xbbcode_tag'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) : array {
$xbbcode_tags = $this->storage
->loadMultiple();
foreach ($xbbcode_tags as $id => $tag) {
/** @var \Drupal\xbbcode\Entity\TagInterface $tag */
$this->derivatives[$id] = [
'id' => 'xbbcode_tag' . TagPluginBase::DERIVATIVE_SEPARATOR . $id,
'label' => $tag
->label(),
'description' => $tag
->getDescription(),
'sample' => $tag
->getSample(),
'name' => $tag
->getName(),
] + $base_plugin_definition;
}
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:: |
|
TagPluginDeriver:: |
protected | property | Entity storage. | |
TagPluginDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
TagPluginDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
TagPluginDeriver:: |
public | function | Constructs a Deriver. |