Initializes a plugin and stores the result in $this->pluginInstances.
string $instance_id: The ID of the plugin instance to initialize.
Overrides PluginBag::initializePlugin
protected function initializePlugin($instance_id) {
if (!$instance_id) {
throw new PluginException(format_string("The block '@block' did not specify a plugin.", array(
'@block' => $this->entity
->id(),
)));
}
if (isset($this->pluginInstances[$instance_id])) {
return;
}
$settings = $this->entity
->get('settings');
try {
$this->pluginInstances[$instance_id] = $this->manager
->createInstance($instance_id, $settings);
} catch (PluginException $e) {
$module = $settings['module'];
// Ignore blocks belonging to disabled modules, but re-throw valid
// exceptions when the module is enabled and the plugin is misconfigured.
if (!$module || \Drupal::moduleHandler()
->moduleExists($module)) {
throw $e;
}
}
}