protected function TipsBag::initializePlugin

Overrides \Drupal\Component\Plugin\PluginBag::initializePlugin().

Overrides PluginBag::initializePlugin

File

drupal/core/modules/tour/lib/Drupal/tour/TipsBag.php, line 57
Contains \Drupal\tour\TipsBag.

Class

TipsBag
A collection of tips.

Namespace

Drupal\tour

Code

protected function initializePlugin($instance_id) {

  // If the tip was initialized before, just return.
  if (isset($this->pluginInstances[$instance_id])) {
    return;
  }
  $type = $this->configurations[$instance_id]['plugin'];
  $definition = $this->manager
    ->getDefinition($type);
  if (isset($definition)) {
    $this
      ->addInstanceID($instance_id);
    $configuration = $definition;

    // Merge the actual configuration into the default configuration.
    if (isset($this->configurations[$instance_id])) {
      $configuration = NestedArray::mergeDeep($configuration, $this->configurations[$instance_id]);
    }
    $this->pluginInstances[$instance_id] = $this->manager
      ->createInstance($type, $configuration);
  }
  else {
    throw new PluginException(format_string("Unknown tip plugin ID '@tip'.", array(
      '@tip' => $instance_id,
    )));
  }
}