You are here

protected function TagPluginManager::getDefaultConfiguration in Extensible BBCode 4.0.x

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

Get a default configuration array based on all available plugins.

Tag plugins have no settings, so we just need to collect plugin IDs.

Return value

array[][] Associative array of: default tag name => ['id' => plugin ID]

3 calls to TagPluginManager::getDefaultConfiguration()
TagPluginManager::clearCachedDefinitions in src/TagPluginManager.php
Clears static and persistent plugin definition caches.
TagPluginManager::getDefaultCollection in src/TagPluginManager.php
Create a plugin collection based on all available plugins.
TagPluginManager::getDefaultNameCollisions in src/TagPluginManager.php
Check for collisions in the default names of plugins.

File

src/TagPluginManager.php, line 130

Class

TagPluginManager
Manages BBCode tags.

Namespace

Drupal\xbbcode

Code

protected function getDefaultConfiguration() : array {
  if ($this->defaultConfiguration === NULL || $this->defaultNameCollisions === NULL) {
    $this->defaultConfiguration = [];
    $this->defaultNameCollisions = [];
    foreach ($this
      ->getDefinedIds() as $plugin_id) {

      /** @var \Drupal\xbbcode\Plugin\TagPluginInterface $plugin */
      try {
        $plugin = $this
          ->createInstance($plugin_id);
        $name = $plugin
          ->getName();
        $this->defaultConfiguration[$name]['id'] = $plugin_id;
        if (!isset($this->defaultNameCollisions[$name])) {
          $this->defaultNameCollisions[$name] = [];
        }
        $this->defaultNameCollisions[$name][] = $plugin_id;
      } catch (PluginException $exception) {
        watchdog_exception('xbbcode', $exception);
      }
    }
    foreach ($this->defaultNameCollisions as $name => $ids) {
      if (count($ids) < 2) {
        unset($this->defaultNameCollisions[$name]);
      }
    }
  }
  return $this->defaultConfiguration;
}