Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BlockContent.php

function BlockContent::getDerivativeDefinitions

Overrides DeriverBase::getDerivativeDefinitions

File

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

Class

BlockContent
Retrieves block plugin definitions for all content 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() ?? $block_content->type->entity
            ->label() . ': ' . $block_content->id();
        $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = [
            $block_content->getConfigDependencyName(),
        ];
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal