You are here

public function BlockContent::getDerivativeDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/block_content/src/Plugin/Derivative/BlockContent.php \Drupal\block_content\Plugin\Derivative\BlockContent::getDerivativeDefinitions()

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

core/modules/block_content/src/Plugin/Derivative/BlockContent.php, line 45

Class

BlockContent
Retrieves block plugin definitions for all custom blocks.

Namespace

Drupal\block_content\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $block_contents = $this->blockContentStorage
    ->loadByProperties([
    'reusable' => TRUE,
  ]);

  // Reset the discovered definitions.
  $this->derivatives = [];

  /** @var \Drupal\block_content\Entity\BlockContent $block_content */
  foreach ($block_contents as $block_content) {
    $this->derivatives[$block_content
      ->uuid()] = $base_plugin_definition;
    $this->derivatives[$block_content
      ->uuid()]['admin_label'] = $block_content
      ->label();
    $this->derivatives[$block_content
      ->uuid()]['config_dependencies']['content'] = [
      $block_content
        ->getConfigDependencyName(),
    ];
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}