You are here

public function AdministrationLanguageNegotiationConditionManager::createInstance in Administration Language Negotiation 8

Creates a pre-configured instance of a plugin.

Parameters

string $plugin_id: The ID of the plugin being instantiated.

array $configuration: An array of configuration relevant to the plugin instance.

Return value

object A fully configured plugin instance.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.

Overrides PluginManagerBase::createInstance

File

src/AdministrationLanguageNegotiationConditionManager.php, line 51

Class

AdministrationLanguageNegotiationConditionManager
Manages administration language negotiation condition plugins.

Namespace

Drupal\administration_language_negotiation

Code

public function createInstance($plugin_id, array $configuration = []) {
  $plugin = $this
    ->getFactory()
    ->createInstance($plugin_id, $configuration);

  // If we receive any context values via config set it into the plugin.
  if (!empty($configuration['context'])) {
    foreach ($configuration['context'] as $name => $context) {
      $plugin
        ->setContextValue($name, $context);
    }
  }
  return $plugin
    ->setExecutableManager($this);
}