mirror of
https://github.com/flarum/framework.git
synced 2025-02-20 23:24:55 +08:00
Update gambit for search API
This commit is contained in:
parent
76d58ababa
commit
27ed9ab636
@ -13,7 +13,7 @@ class StickySearchModifier
|
||||
public function reorderSearch(DiscussionSearchWillBePerformed $event)
|
||||
{
|
||||
if ($event->criteria->sort === null) {
|
||||
$query = $event->searcher->query();
|
||||
$query = $event->searcher->getQuery();
|
||||
|
||||
if (!is_array($query->orders)) {
|
||||
$query->orders = [];
|
||||
|
@ -10,7 +10,7 @@ class StickyGambit extends GambitAbstract
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pattern = 'sticky:(true|false)';
|
||||
protected $pattern = 'is:sticky';
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return void
|
||||
*/
|
||||
public function conditions($matches, SearcherInterface $searcher)
|
||||
protected function conditions(SearcherInterface $searcher, array $matches, $negate)
|
||||
{
|
||||
$sticky = $matches[1] === 'true';
|
||||
|
||||
$searcher->query()->where('is_sticky', $sticky);
|
||||
$searcher->getQuery()->where('is_sticky', ! $negate);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user