class SearchLocalTask in Drupal 8
Same name and namespace in other branches
- 9 core/modules/search/src/Plugin/Derivative/SearchLocalTask.php \Drupal\search\Plugin\Derivative\SearchLocalTask
Provides local tasks for each search page.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\search\Plugin\Derivative\SearchLocalTask implements ContainerDeriverInterface
Expanded class hierarchy of SearchLocalTask
1 string reference to 'SearchLocalTask'
- search.links.task.yml in core/
modules/ search/ search.links.task.yml - core/modules/search/search.links.task.yml
File
- core/
modules/ search/ src/ Plugin/ Derivative/ SearchLocalTask.php, line 13
Namespace
Drupal\search\Plugin\DerivativeView source
class SearchLocalTask extends DeriverBase implements ContainerDeriverInterface {
/**
* The search page repository.
*
* @var \Drupal\search\SearchPageRepositoryInterface
*/
protected $searchPageRepository;
/**
* Constructs a new SearchLocalTask.
*
* @param \Drupal\search\SearchPageRepositoryInterface $search_page_repository
* The search page repository.
*/
public function __construct(SearchPageRepositoryInterface $search_page_repository) {
$this->searchPageRepository = $search_page_repository;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('search.search_page_repository'));
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
SearchLocalTask:: |
protected | property | The search page repository. | |
SearchLocalTask:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
SearchLocalTask:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
SearchLocalTask:: |
public | function | Constructs a new SearchLocalTask. |