You are here

public function ConditionPluginCollection::getConfiguration in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Condition/ConditionPluginCollection.php \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration()

Gets the current configuration of all plugins in this collection.

Return value

array An array of up-to-date plugin configuration.

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']);
    if ($default_config === $instance_config) {
      unset($configuration[$instance_id]);
    }
  }
  return $configuration;
}