You are here

public function InlineBlockDeriver::getDerivativeDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php \Drupal\layout_builder\Plugin\Derivative\InlineBlockDeriver::getDerivativeDefinitions()
  2. 10 core/modules/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php \Drupal\layout_builder\Plugin\Derivative\InlineBlockDeriver::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/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php, line 47

Class

InlineBlockDeriver
Provides inline block plugin definitions for all custom block types.

Namespace

Drupal\layout_builder\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  if ($this->entityTypeManager
    ->hasDefinition('block_content_type')) {
    $block_content_types = $this->entityTypeManager
      ->getStorage('block_content_type')
      ->loadMultiple();
    foreach ($block_content_types as $id => $type) {
      $this->derivatives[$id] = $base_plugin_definition;
      $this->derivatives[$id]['admin_label'] = $type
        ->label();
      $this->derivatives[$id]['config_dependencies'][$type
        ->getConfigDependencyKey()][] = $type
        ->getConfigDependencyName();
    }
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}