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 = [];
if (!$this->isSearchExecutable()) {
return $results;
}
return [
[
'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'] = '
Test page text is here
';
foreach ($results as $entry) {
$output[] = [
'#theme' => 'search_result',
'#result' => $entry,
'#plugin_id' => 'search_extra_type_search',
];
}
$pager = [
'#type' => 'pager',
];
$output['suffix']['#markup'] = '
' . \Drupal::service('renderer')->render($pager);
return $output;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Output form for defining rank factor weights.
$form['extra_type_settings'] = [
'#type' => 'fieldset',
'#title' => t('Extra type settings'),
'#tree' => TRUE,
];
$form['extra_type_settings']['boost'] = [
'#type' => 'select',
'#title' => t('Boost method'),
'#options' => [
'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(['extra_type_settings', 'boost']);
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'boost' => 'bi',
];
}
}