You are here

public static function TagPluginCollection::createFromTags in Extensible BBCode 8.3

Same name and namespace in other branches
  1. 4.0.x 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 40

Class

TagPluginCollection
A collection of tag plugins.

Namespace

Drupal\xbbcode

Code

public static function createFromTags(array $tags) {
  $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;
}