You are here

public function SearchLocalTask::getDerivativeDefinitions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/search/src/Plugin/Derivative/SearchLocalTask.php \Drupal\search\Plugin\Derivative\SearchLocalTask::getDerivativeDefinitions()
  2. 10 core/modules/search/src/Plugin/Derivative/SearchLocalTask.php \Drupal\search\Plugin\Derivative\SearchLocalTask::getDerivativeDefinitions()

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

File

core/modules/search/src/Plugin/Derivative/SearchLocalTask.php, line 44

Class

SearchLocalTask
Provides local tasks for each search page.

Namespace

Drupal\search\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  if ($default = $this->searchPageRepository
    ->getDefaultSearchPage()) {
    $active_search_pages = $this->searchPageRepository
      ->getActiveSearchPages();
    foreach ($this->searchPageRepository
      ->sortSearchPages($active_search_pages) as $entity_id => $entity) {
      $this->derivatives[$entity_id] = [
        'title' => $entity
          ->label(),
        'route_name' => 'search.view_' . $entity_id,
        'base_route' => 'search.plugins:' . $default,
        'weight' => $entity
          ->getWeight(),
      ];
    }
  }
  return $this->derivatives;
}