function ConditionPluginCollection::getConfiguration
Same name in other branches
- 9 core/lib/Drupal/Core/Condition/ConditionPluginCollection.php \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration()
- 8.9.x core/lib/Drupal/Core/Condition/ConditionPluginCollection.php \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration()
- 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\ConditionCode
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);
// With PHP 8 type juggling, there should not be an issue using equal
// operator instead of identical operator. Allowing looser comparison here
// will prevent configuration from being erroneously exported when values
// are updated via form elements that return values of the wrong type, for
// example, '0'/'1' vs FALSE/TRUE.
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.