class SearchExtraTypeSearch in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php \Drupal\search_extra_type\Plugin\Search\SearchExtraTypeSearch
Executes a dummy keyword search.
Plugin annotation
@SearchPlugin(
id = "search_extra_type_search",
title = @Translation("Dummy search type")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\search\Plugin\SearchPluginBase implements RefinableCacheableDependencyInterface, ContainerFactoryPluginInterface, SearchInterface uses RefinableCacheableDependencyTrait
- class \Drupal\search\Plugin\ConfigurableSearchPluginBase implements ConfigurableSearchPluginInterface
- class \Drupal\search_extra_type\Plugin\Search\SearchExtraTypeSearch uses UrlGeneratorTrait
- class \Drupal\search\Plugin\ConfigurableSearchPluginBase implements ConfigurableSearchPluginInterface
- class \Drupal\search\Plugin\SearchPluginBase implements RefinableCacheableDependencyInterface, ContainerFactoryPluginInterface, SearchInterface uses RefinableCacheableDependencyTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, StringTranslationTrait
Expanded class hierarchy of SearchExtraTypeSearch
File
- core/
modules/ search/ tests/ modules/ search_extra_type/ src/ Plugin/ Search/ SearchExtraTypeSearch.php, line 24 - Contains \Drupal\search_extra_type\Plugin\Search\SearchExtraTypeSearch.
Namespace
Drupal\search_extra_type\Plugin\SearchView source
class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
use UrlGeneratorTrait;
/**
* {@inheritdoc}
*/
public function setSearch($keywords, array $parameters, array $attributes) {
if (empty($parameters['search_conditions'])) {
$parameters['search_conditions'] = '';
}
parent::setSearch($keywords, $parameters, $attributes);
}
/**
* Verifies if the given parameters are valid enough to execute a search for.
*
* @return bool
* TRUE if there are keywords or search conditions in the query.
*/
public function isSearchExecutable() {
return (bool) ($this->keywords || !empty($this->searchParameters['search_conditions']));
}
/**
* Execute the search.
*
* This is a dummy search, so when search "executes", we just return a dummy
* result containing the keywords and a list of conditions.
*
* @return array
* A structured list of search results
*/
public function execute() {
$results = array();
if (!$this
->isSearchExecutable()) {
return $results;
}
return array(
array(
'link' => Url::fromRoute('test_page_test.test_page')
->toString(),
'type' => 'Dummy result type',
'title' => 'Dummy title',
'snippet' => SafeMarkup::format("Dummy search snippet to display. Keywords: @keywords\n\nConditions: @search_parameters", [
'@keywords' => $this->keywords,
'@search_parameters' => print_r($this->searchParameters, TRUE),
]),
),
);
}
/**
* {@inheritdoc}
*/
public function buildResults() {
$results = $this
->execute();
$output['prefix']['#markup'] = '<h2>Test page text is here</h2> <ol class="search-results">';
foreach ($results as $entry) {
$output[] = array(
'#theme' => 'search_result',
'#result' => $entry,
'#plugin_id' => 'search_extra_type_search',
);
}
$pager = array(
'#type' => 'pager',
);
$output['suffix']['#markup'] = '</ol>' . drupal_render($pager);
return $output;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Output form for defining rank factor weights.
$form['extra_type_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Extra type settings'),
'#tree' => TRUE,
);
$form['extra_type_settings']['boost'] = array(
'#type' => 'select',
'#title' => t('Boost method'),
'#options' => array(
'bi' => t('Bistromathic'),
'ii' => t('Infinite Improbability'),
),
'#default_value' => $this->configuration['boost'],
);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['boost'] = $form_state
->getValue(array(
'extra_type_settings',
'boost',
));
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return array(
'boost' => 'bi',
);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableSearchPluginBase:: |
protected | property | The unique ID for the search page using this plugin. | |
ConfigurableSearchPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
ConfigurableSearchPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurablePluginInterface:: |
|
ConfigurableSearchPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurablePluginInterface:: |
|
ConfigurableSearchPluginBase:: |
public | function |
Sets the ID for the search page using this plugin. Overrides ConfigurableSearchPluginInterface:: |
|
ConfigurableSearchPluginBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
ConfigurableSearchPluginBase:: |
public | function |
Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 2 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
RefinableCacheableDependencyTrait:: |
protected | property | Cache contexts. | |
RefinableCacheableDependencyTrait:: |
protected | property | Cache max-age. | |
RefinableCacheableDependencyTrait:: |
protected | property | Cache tags. | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | 4 | |
RefinableCacheableDependencyTrait:: |
public | function | 4 | |
RefinableCacheableDependencyTrait:: |
public | function | 4 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
SearchExtraTypeSearch:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
SearchExtraTypeSearch:: |
public | function |
Executes the search and builds render arrays for the result items. Overrides SearchPluginBase:: |
|
SearchExtraTypeSearch:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableSearchPluginBase:: |
|
SearchExtraTypeSearch:: |
public | function |
Execute the search. Overrides SearchInterface:: |
|
SearchExtraTypeSearch:: |
public | function |
Verifies if the given parameters are valid enough to execute a search for. Overrides SearchPluginBase:: |
|
SearchExtraTypeSearch:: |
public | function |
Sets the keywords, parameters, and attributes to be used by execute(). Overrides SearchPluginBase:: |
|
SearchExtraTypeSearch:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
SearchPluginBase:: |
protected | property | The keywords to use in a search. | |
SearchPluginBase:: |
protected | property | Array of attributes - usually from the request object. | |
SearchPluginBase:: |
protected | property | Array of parameters from the query string from the request. | |
SearchPluginBase:: |
public | function |
Builds the URL GET query parameters array for search. Overrides SearchInterface:: |
1 |
SearchPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
2 |
SearchPluginBase:: |
public | function |
Returns the currently set attributes (from the request). Overrides SearchInterface:: |
|
SearchPluginBase:: |
public | function |
Returns the searching help. Overrides SearchInterface:: |
1 |
SearchPluginBase:: |
public | function |
Returns the currently set keywords of the plugin instance. Overrides SearchInterface:: |
|
SearchPluginBase:: |
public | function |
Returns the current parameters set using setSearch(). Overrides SearchInterface:: |
|
SearchPluginBase:: |
public | function |
Returns the search index type this plugin uses. Overrides SearchInterface:: |
1 |
SearchPluginBase:: |
public | function |
Alters the search form when being built for a given plugin. Overrides SearchInterface:: |
1 |
SearchPluginBase:: |
public | function |
Provides a suggested title for a page of search results. Overrides SearchInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Returns a redirect response object for the specified route. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |