You are here

public function FacetBlockDeriver::getDerivativeDefinitions in Facets 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 DeriverInterface::getDerivativeDefinitions

See also

getDerivativeDefinition()

1 call to FacetBlockDeriver::getDerivativeDefinitions()
FacetBlockDeriver::getDerivativeDefinition in src/Plugin/Block/FacetBlockDeriver.php
Gets the definition of a derivative plugin.

File

src/Plugin/Block/FacetBlockDeriver.php, line 52

Class

FacetBlockDeriver
This deriver creates a block for every facet that has been created.

Namespace

Drupal\facets\Plugin\Block

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $base_plugin_id = $base_plugin_definition['id'];
  if (!isset($this->derivatives[$base_plugin_id])) {
    $plugin_derivatives = [];

    /** @var \Drupal\facets\FacetInterface[] $all_facets */
    $all_facets = $this->facetStorage
      ->loadMultiple();
    foreach ($all_facets as $facet) {
      $machine_name = $facet
        ->id();
      $plugin_derivatives[$machine_name] = [
        'id' => $base_plugin_id . PluginBase::DERIVATIVE_SEPARATOR . $machine_name,
        'label' => $this
          ->t('Facet: :facet', [
          ':facet' => $facet
            ->getName(),
        ]),
        'admin_label' => $facet
          ->getName(),
        'description' => $this
          ->t('Facet'),
      ] + $base_plugin_definition;
    }
    $this->derivatives[$base_plugin_id] = $plugin_derivatives;
  }
  return $this->derivatives[$base_plugin_id];
}