function BlockPluginCollection::initializePlugin

Same name in other branches
  1. 8.9.x core/modules/block/src/BlockPluginCollection.php \Drupal\block\BlockPluginCollection::initializePlugin()
  2. 10 core/modules/block/src/BlockPluginCollection.php \Drupal\block\BlockPluginCollection::initializePlugin()
  3. 11.x core/modules/block/src/BlockPluginCollection.php \Drupal\block\BlockPluginCollection::initializePlugin()

Overrides DefaultSingleLazyPluginCollection::initializePlugin

File

core/modules/block/src/BlockPluginCollection.php, line 51

Class

BlockPluginCollection
Provides a collection of block plugins.

Namespace

Drupal\block

Code

protected function initializePlugin($instance_id) {
    if (!$instance_id) {
        throw new PluginException("The block '{$this->blockId}' 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;
        }
    }
}

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