You are here

protected function BlockPluginCollection::initializePlugin in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block/src/BlockPluginCollection.php \Drupal\block\BlockPluginCollection::initializePlugin()
  2. 9 core/modules/block/src/BlockPluginCollection.php \Drupal\block\BlockPluginCollection::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;
    }
  }
}