You are here

protected function FrontendEnvironmentPluginCollection::initializePlugin in Build Hooks 3.x

Same name and namespace in other branches
  1. 8.2 src/FrontendEnvironmentPluginCollection.php \Drupal\build_hooks\FrontendEnvironmentPluginCollection::initializePlugin()

Initializes and stores a plugin.

Parameters

string $instance_id: The ID of the plugin instance to initialize.

Overrides DefaultSingleLazyPluginCollection::initializePlugin

File

src/FrontendEnvironmentPluginCollection.php, line 42

Class

FrontendEnvironmentPluginCollection
Provides a collection of front plugins.

Namespace

Drupal\build_hooks

Code

protected function initializePlugin($instance_id) {
  if (!$instance_id) {
    throw new PluginException("The frontend environment '{$this->frontendEnvironmentId}' did not specify a plugin.");
  }
  try {
    parent::initializePlugin($instance_id);
  } catch (PluginException $e) {
    $module = $this->configuration['provider'];

    // Ignore blocks belonging to uninstalled modules, but re-throw valid
    // exceptions when the module is installed and the plugin is
    // misconfigured.
    if (!$module || \Drupal::moduleHandler()
      ->moduleExists($module)) {
      throw $e;
    }
  }
}