public function CustomBlock::getDerivativeDefinitions

Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().

Retrieves custom block definitions from storage.

Overrides DerivativeInterface::getDerivativeDefinitions

1 call to CustomBlock::getDerivativeDefinitions()
CustomBlock::getDerivativeDefinition in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php
Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition().

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php, line 42
Contains \Drupal\custom_block\Plugin\Derivative\CustomBlock.

Class

CustomBlock
Retrieves block plugin definitions for all custom blocks.

Namespace

Drupal\custom_block\Plugin\Derivative

Code

public function getDerivativeDefinitions(array $base_plugin_definition) {
  $custom_blocks = entity_load_multiple('custom_block');
  foreach ($custom_blocks as $custom_block) {
    $this->derivatives[$custom_block->uuid->value] = $base_plugin_definition;
    $this->derivatives[$custom_block->uuid->value]['admin_label'] = $custom_block->info->value;
  }
  return $this->derivatives;
}