function DefaultLazyPluginCollection::setConfiguration

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php \Drupal\Core\Plugin\DefaultLazyPluginCollection::setConfiguration()
  2. 8.9.x core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php \Drupal\Core\Plugin\DefaultLazyPluginCollection::setConfiguration()
  3. 11.x core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php \Drupal\Core\Plugin\DefaultLazyPluginCollection::setConfiguration()

Overrides LazyPluginCollection::setConfiguration

File

core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php, line 130

Class

DefaultLazyPluginCollection
Provides a default plugin collection for a plugin type.

Namespace

Drupal\Core\Plugin

Code

public function setConfiguration($configuration) {
    if (!is_array($configuration)) {
        @trigger_error('Calling ' . __METHOD__ . '() with a non-array argument is deprecated in drupal:10.3.0 and will fail in drupal:11.0.0. See https://www.drupal.org/node/3406191', E_USER_DEPRECATED);
        $configuration = [];
    }
    // Track each instance ID as it is updated.
    $unprocessed_instance_ids = $this->getInstanceIds();
    foreach ($configuration as $instance_id => $instance_configuration) {
        $this->setInstanceConfiguration($instance_id, $instance_configuration);
        // Remove this instance ID from the list being updated.
        unset($unprocessed_instance_ids[$instance_id]);
    }
    // Remove remaining instances that had no configuration specified for them.
    foreach ($unprocessed_instance_ids as $unprocessed_instance_id) {
        $this->removeInstanceId($unprocessed_instance_id);
    }
    return $this;
}

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