You are here

public function DefaultLazyPluginCollection::setConfiguration in Plug 7

Sets the configuration for all plugins in this collection.

Parameters

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

Return value

$this

Overrides LazyPluginCollection::setConfiguration

File

lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php, line 133
Contains \Drupal\Core\Plugin\DefaultLazyPluginCollection.

Class

DefaultLazyPluginCollection
Provides a default plugin collection for a plugin type.

Namespace

Drupal\Core\Plugin

Code

public function setConfiguration($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;
}