function DefaultLazyPluginCollection::getPluginId

Get the plugin ID for an instance.

Parameters

string $instance_id: The instance ID.

Return value

string The plugin ID for the instance.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if the plugin key is not present in the instance configuration.

1 call to DefaultLazyPluginCollection::getPluginId()
DefaultLazyPluginCollection::sortHelper in core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php
Provides uasort() callback to sort plugins.

File

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

Class

DefaultLazyPluginCollection
Provides a default plugin collection for a plugin type.

Namespace

Drupal\Core\Plugin

Code

protected function getPluginId(string $instance_id) : string {
  if (isset($this->pluginInstances[$instance_id])) {
    return $this->pluginInstances[$instance_id]
      ->getPluginId();
  }
  return $this->configurations[$instance_id][$this->pluginKey] ?? throw new PluginNotFoundException($instance_id);
}

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