function ConditionPluginCollection::getConfiguration

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Condition/ConditionPluginCollection.php \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration()
  2. 10 core/lib/Drupal/Core/Condition/ConditionPluginCollection.php \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration()
  3. 11.x core/lib/Drupal/Core/Condition/ConditionPluginCollection.php \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration()

Overrides DefaultLazyPluginCollection::getConfiguration

File

core/lib/Drupal/Core/Condition/ConditionPluginCollection.php, line 32

Class

ConditionPluginCollection
Provides a collection of condition plugins.

Namespace

Drupal\Core\Condition

Code

public function getConfiguration() {
    $configuration = parent::getConfiguration();
    // Remove configuration if it matches the defaults.
    foreach ($configuration as $instance_id => $instance_config) {
        $default_config = [];
        $default_config['id'] = $instance_id;
        $default_config += $this->get($instance_id)
            ->defaultConfiguration();
        // In order to determine if a plugin is configured, we must compare it to
        // its default configuration. The default configuration of a plugin does
        // not contain context_mapping and it is not used when the plugin is not
        // configured, so remove the context_mapping from the instance config to
        // compare the remaining values.
        unset($instance_config['context_mapping']);
        ksort($default_config);
        ksort($instance_config);
        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.