You are here

public function FacetsSummaryBlockDeriver::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 FacetsSummaryBlockDeriver::getDerivativeDefinitions()
FacetsSummaryBlockDeriver::getDerivativeDefinition in modules/facets_summary/src/Plugin/Block/FacetsSummaryBlockDeriver.php
Gets the definition of a derivative plugin.

File

modules/facets_summary/src/Plugin/Block/FacetsSummaryBlockDeriver.php, line 52

Class

FacetsSummaryBlockDeriver
This deriver creates a block for every facet source.

Namespace

Drupal\facets_summary\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_summary\FacetsSummaryInterface[] $all_facets_summaries */
    $all_facets_summaries = $this->facetsSummaryStorage
      ->loadMultiple();
    foreach ($all_facets_summaries as $facets_summary) {
      $machine_name = $facets_summary
        ->id();
      $plugin_derivatives[$machine_name] = [
        'id' => $base_plugin_id . PluginBase::DERIVATIVE_SEPARATOR . $machine_name,
        'label' => $this
          ->t('Facet Summary: :facet_summary', [
          ':facet_summary' => $facets_summary
            ->getName(),
        ]),
        'admin_label' => $facets_summary
          ->getName(),
        'description' => $this
          ->t('Facets Summary'),
      ] + $base_plugin_definition;
    }
    $this->derivatives[$base_plugin_id] = $plugin_derivatives;
  }
  return $this->derivatives[$base_plugin_id];
}