function FilterPluginCollection::getConfiguration

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

Overrides DefaultLazyPluginCollection::getConfiguration

File

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

Class

FilterPluginCollection
A collection of filters.

Namespace

Drupal\filter

Code

public function getConfiguration() {
    $configuration = parent::getConfiguration();
    // Remove configuration if it matches the defaults. In self::getAll(), we
    // load all available filters, in addition to the enabled filters stored in
    // configuration. In order to prevent those from bleeding through to the
    // stored configuration, remove all filters that match the default values.
    // Because filters are disabled by default, this will never remove the
    // configuration of an enabled filter.
    foreach ($configuration as $instance_id => $instance_config) {
        $default_config = [];
        $default_config['id'] = $instance_id;
        $default_config += $this->get($instance_id)
            ->defaultConfiguration();
        if ($default_config === $instance_config) {
            unset($configuration[$instance_id]);
        }
    }
    return $configuration;
}

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