function ViewsExposedFilterBlock::getDerivativeDefinitions

Same name and namespace in other branches
  1. 10 core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php \Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock::getDerivativeDefinitions()
  2. 9 core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php \Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock::getDerivativeDefinitions()
  3. 8.9.x core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php \Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock::getDerivativeDefinitions()
  4. main core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php \Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock::getDerivativeDefinitions()

Gets the definition of all derivatives of a base plugin.

Parameters

array|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface $base_plugin_definition: The definition of the base plugin from which the derivative plugin is derived. It is maybe an entire object or just some array, depending on the discovery mechanism.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverInterface::getDerivativeDefinitions

1 call to ViewsExposedFilterBlock::getDerivativeDefinitions()
ViewsExposedFilterBlock::getDerivativeDefinition in core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
Gets the definition of a derivative plugin.

File

core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php, line 77

Class

ViewsExposedFilterBlock
Provides block plugin definitions for all Views exposed filters.

Namespace

Drupal\views\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  // Check all Views for displays with an exposed filter block.
  foreach ($this->viewStorage
    ->loadMultiple() as $view) {
    // Do not return results for disabled views.
    if (!$view->status()) {
      continue;
    }
    $executable = $view->getExecutable();
    $executable->initDisplay();
    foreach ($executable->displayHandlers as $display) {
      if (isset($display) && $display->getOption('exposed_block')) {
        // Add a block definition for the block.
        if ($display->usesExposedFormInBlock()) {
          $delta = $view->id() . '-' . $display->display['id'];
          $desc = $this->t('Exposed form: @view-@display_id', [
            '@view' => $view->id(),
            '@display_id' => $display->display['id'],
          ]);
          $this->derivatives[$delta] = [
            'admin_label' => $desc,
            'config_dependencies' => [
              'config' => [
                $view->getConfigDependencyName(),
              ],
            ],
          ];
          $this->derivatives[$delta] += $base_plugin_definition;
        }
      }
    }
  }
  return $this->derivatives;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.