mirror of
https://github.com/flarum/core.git
synced 2025-07-21 16:51:34 +02:00
Update gambit for search API
This commit is contained in:
@@ -13,7 +13,7 @@ class StickySearchModifier
|
|||||||
public function reorderSearch(DiscussionSearchWillBePerformed $event)
|
public function reorderSearch(DiscussionSearchWillBePerformed $event)
|
||||||
{
|
{
|
||||||
if ($event->criteria->sort === null) {
|
if ($event->criteria->sort === null) {
|
||||||
$query = $event->searcher->query();
|
$query = $event->searcher->getQuery();
|
||||||
|
|
||||||
if (!is_array($query->orders)) {
|
if (!is_array($query->orders)) {
|
||||||
$query->orders = [];
|
$query->orders = [];
|
||||||
|
@@ -10,7 +10,7 @@ class StickyGambit extends GambitAbstract
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $pattern = 'sticky:(true|false)';
|
protected $pattern = 'is:sticky';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply conditions to the searcher, given matches from the gambit's
|
* Apply conditions to the searcher, given matches from the gambit's
|
||||||
@@ -20,10 +20,8 @@ class StickyGambit extends GambitAbstract
|
|||||||
* @param \Flarum\Core\Search\SearcherInterface $searcher
|
* @param \Flarum\Core\Search\SearcherInterface $searcher
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function conditions($matches, SearcherInterface $searcher)
|
protected function conditions(SearcherInterface $searcher, array $matches, $negate)
|
||||||
{
|
{
|
||||||
$sticky = $matches[1] === 'true';
|
$searcher->getQuery()->where('is_sticky', ! $negate);
|
||||||
|
|
||||||
$searcher->query()->where('is_sticky', $sticky);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user