You are here

public function TagPluginDeriver::getDerivativeDefinitions in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Derivative/TagPluginDeriver.php \Drupal\xbbcode\Plugin\Derivative\TagPluginDeriver::getDerivativeDefinitions()

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/TagPluginDeriver.php, line 44

Class

TagPluginDeriver
Provide a tag plugin for each XBBCodeCustom entity.

Namespace

Drupal\xbbcode\Plugin\Derivative

Code

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);
}