You are here

public function DefaultSingleLazyPluginCollection::addInstanceId in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection::addInstanceId()

Adds an instance ID to the available instance IDs.

Parameters

string $id: The ID of the plugin instance to add.

array|null $configuration: (optional) The configuration used by this instance. Defaults to NULL.

Overrides LazyPluginCollection::addInstanceId

1 call to DefaultSingleLazyPluginCollection::addInstanceId()
DefaultSingleLazyPluginCollection::__construct in core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php
Constructs a new DefaultSingleLazyPluginCollection object.

File

core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php, line 93

Class

DefaultSingleLazyPluginCollection
Provides a default plugin collection for a plugin type.

Namespace

Drupal\Core\Plugin

Code

public function addInstanceId($id, $configuration = NULL) {
  $this->instanceId = $id;

  // Reset the list of instance IDs since there can be only one.
  $this->instanceIds = [];
  parent::addInstanceId($id, $configuration);
  if ($configuration !== NULL) {
    $this
      ->setConfiguration($configuration);
  }
}