You are here

public static function TagPluginCollection::createFromTags in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/TagPluginCollection.php \Drupal\xbbcode\TagPluginCollection::createFromTags()

Create a plugin collection directly from an array of tag plugins.

Parameters

\Drupal\xbbcode\Plugin\TagPluginInterface[] $tags: The tag plugins.

Return value

static A plugin collection.

1 call to TagPluginCollection::createFromTags()
TagPluginCollection::getTable in src/TagPluginCollection.php
Generate a table of available tags, with samples.

File

src/TagPluginCollection.php, line 39

Class

TagPluginCollection
A collection of tag plugins.

Namespace

Drupal\xbbcode

Code

public static function createFromTags(array $tags) : self {
  $configurations = [];
  foreach ($tags as $name => $tag) {
    $configurations[$name]['id'] = $tag
      ->getPluginId();
  }
  $collection = new static(\Drupal::service('plugin.manager.xbbcode'), $configurations);
  $collection->pluginInstances = $tags;
  return $collection;
}