function FilterPluginCollection::getAll

Same name in other branches
  1. 9 core/modules/filter/src/FilterPluginCollection.php \Drupal\filter\FilterPluginCollection::getAll()
  2. 8.9.x core/modules/filter/src/FilterPluginCollection.php \Drupal\filter\FilterPluginCollection::getAll()
  3. 11.x core/modules/filter/src/FilterPluginCollection.php \Drupal\filter\FilterPluginCollection::getAll()

Retrieves filter definitions and creates an instance for each filter.

This is exclusively used for the text format administration page, on which all available filter plugins are exposed, regardless of whether the current text format has an active instance.

@todo Refactor text format administration to actually construct/create and destruct/remove actual filter plugin instances, using a library approach à la blocks.

1 call to FilterPluginCollection::getAll()
FilterPluginCollection::sort in core/modules/filter/src/FilterPluginCollection.php
Sorts all plugin instances in this collection.

File

core/modules/filter/src/FilterPluginCollection.php, line 40

Class

FilterPluginCollection
A collection of filters.

Namespace

Drupal\filter

Code

public function getAll() {
    // Retrieve all available filter plugin definitions.
    if (!$this->definitions) {
        $this->definitions = $this->manager
            ->getDefinitions();
        // Do not allow the null filter to be used directly, only as a fallback.
        unset($this->definitions['filter_null']);
    }
    // Ensure that there is an instance of all available filters.
    // Note that getDefinitions() are keyed by $plugin_id. $instance_id is the
    // $plugin_id for filters, since a single filter plugin can only exist once
    // in a format.
    foreach ($this->definitions as $plugin_id => $definition) {
        if (!isset($this->pluginInstances[$plugin_id])) {
            $this->initializePlugin($plugin_id);
        }
    }
    return $this->pluginInstances;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.