Update gambit for search API

This commit is contained in:
Toby Zerner 2015-06-26 12:21:47 +09:30
parent 76d58ababa
commit 27ed9ab636
2 changed files with 4 additions and 6 deletions

View File

@ -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 = [];

View File

@ -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);
}
}