You are here

public function PdbBlockDeriver::getDerivativeDefinitions in Decoupled Blocks 8

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()

2 calls to PdbBlockDeriver::getDerivativeDefinitions()
Ng2BlockDeriver::getDerivativeDefinitions in modules/pdb_ng2/src/Plugin/Derivative/Ng2BlockDeriver.php
Gets the definition of all derivatives of a base plugin.
ReactBlockDeriver::getDerivativeDefinitions in modules/pdb_react/src/Plugin/Derivative/ReactBlockDeriver.php
Gets the definition of all derivatives of a base plugin.
2 methods override PdbBlockDeriver::getDerivativeDefinitions()
Ng2BlockDeriver::getDerivativeDefinitions in modules/pdb_ng2/src/Plugin/Derivative/Ng2BlockDeriver.php
Gets the definition of all derivatives of a base plugin.
ReactBlockDeriver::getDerivativeDefinitions in modules/pdb_react/src/Plugin/Derivative/ReactBlockDeriver.php
Gets the definition of all derivatives of a base plugin.

File

src/Plugin/Derivative/PdbBlockDeriver.php, line 46

Class

PdbBlockDeriver
Provides a deriver for pdb blocks.

Namespace

Drupal\pdb\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  // Get all custom blocks which should be rediscovered.
  $components = $this->componentDiscovery
    ->getComponents();
  foreach ($components as $block_id => $block_info) {
    $this->derivatives[$block_id] = $base_plugin_definition;
    $this->derivatives[$block_id]['info'] = $block_info->info;
    $this->derivatives[$block_id]['admin_label'] = $block_info->info['name'];
    $this->derivatives[$block_id]['cache'] = [
      'max-age' => 0,
    ];

    // Only set category if available. Defaults to provider.
    if (isset($block_info->info['category'])) {
      $this->derivatives[$block_id]['category'] = $block_info->info['category'];
    }
    if (isset($block_info->info['contexts'])) {
      $this->derivatives[$block_id]['context_definitions'] = $this
        ->createContexts($block_info->info['contexts']);
    }
  }
  return $this->derivatives;
}