class Score in Drupal 10
Same name in this branch
- 10 core/modules/search/src/Plugin/views/sort/Score.php \Drupal\search\Plugin\views\sort\Score
- 10 core/modules/search/src/Plugin/views/field/Score.php \Drupal\search\Plugin\views\field\Score
Same name and namespace in other branches
- 8 core/modules/search/src/Plugin/views/sort/Score.php \Drupal\search\Plugin\views\sort\Score
- 9 core/modules/search/src/Plugin/views/sort/Score.php \Drupal\search\Plugin\views\sort\Score
Sort handler for sorting by search score.
Plugin annotation
@ViewsSort("search_score");
Hierarchy
- class \Drupal\views\Plugin\views\sort\SortPluginBase extends \Drupal\views\Plugin\views\HandlerBase implements CacheableDependencyInterface
- class \Drupal\search\Plugin\views\sort\Score
Expanded class hierarchy of Score
Related topics
1 string reference to 'Score'
- NodeViewsData::getViewsData in core/
modules/ node/ src/ NodeViewsData.php
File
- core/
modules/ search/ src/ Plugin/ views/ sort/ Score.php, line 14
Namespace
Drupal\search\Plugin\views\sortView source
class Score extends SortPluginBase {
/**
* {@inheritdoc}
*/
public function query() {
// Check to see if the search filter/argument added 'score' to the table.
// Our filter stores it as $handler->search_score -- and we also
// need to check its relationship to make sure that we're using the same
// one or obviously this won't work.
foreach ([
'filter',
'argument',
] as $type) {
foreach ($this->view->{$type} as $handler) {
if (isset($handler->search_score) && $handler->relationship == $this->relationship) {
$this->query
->addOrderBy(NULL, NULL, $this->options['order'], $handler->search_score);
$this->tableAlias = $handler->tableAlias;
return;
}
}
}
// Do nothing if there is no filter/argument in place. There is no way
// to sort on scores.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Score:: |
public | function |
Called to add the sort to a query. Overrides SortPluginBase:: |
|
SortPluginBase:: |
public | function | Display whether or not the sort order is ascending or descending. | |
SortPluginBase:: |
public | function | ||
SortPluginBase:: |
public | function | Basic options for all sort criteria. | 2 |
SortPluginBase:: |
public | function | Determine if a sort can be exposed. | |
SortPluginBase:: |
public | function | Provide default options for exposed sorts. | |
SortPluginBase:: |
protected | function | 1 | |
SortPluginBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
|
SortPluginBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
|
SortPluginBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
|
SortPluginBase:: |
public | function | Shortcut to display the expose/hide button. | |
SortPluginBase:: |
protected | function | Shortcut to display the value form. | |
SortPluginBase:: |
protected | function | Provide a list of options for the default sort form. | |
SortPluginBase:: |
public | function | ||
SortPluginBase:: |
protected | function | ||
SortPluginBase:: |
public | function | Simple submit handler. | |
SortPluginBase:: |
public static | function | ||
SortPluginBase:: |
public | function | Validate the options form. | |
SortPluginBase:: |
public | function | Simple validate handler. |