function NodeSearch::buildConfigurationForm
Same name in other branches
- 9 core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::buildConfigurationForm()
- 10 core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::buildConfigurationForm()
- 11.x core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::buildConfigurationForm()
Overrides PluginFormInterface::buildConfigurationForm
File
-
core/
modules/ node/ src/ Plugin/ Search/ NodeSearch.php, line 833
Class
- NodeSearch
- Handles searching for node entities using the Search module index.
Namespace
Drupal\node\Plugin\SearchCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Output form for defining rank factor weights.
$form['content_ranking'] = [
'#type' => 'details',
'#title' => t('Content ranking'),
'#open' => TRUE,
];
$form['content_ranking']['info'] = [
'#markup' => '<p><em>' . $this->t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em></p>',
];
// Prepare table.
$header = [
$this->t('Factor'),
$this->t('Influence'),
];
$form['content_ranking']['rankings'] = [
'#type' => 'table',
'#header' => $header,
];
// Note: reversed to reflect that higher number = higher ranking.
$range = range(0, 10);
$options = array_combine($range, $range);
foreach ($this->getRankings() as $var => $values) {
$form['content_ranking']['rankings'][$var]['name'] = [
'#markup' => $values['title'],
];
$form['content_ranking']['rankings'][$var]['value'] = [
'#type' => 'select',
'#options' => $options,
'#attributes' => [
'aria-label' => $this->t("Influence of '@title'", [
'@title' => $values['title'],
]),
],
'#default_value' => isset($this->configuration['rankings'][$var]) ? $this->configuration['rankings'][$var] : 0,
];
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.