Skip to content

Commit

Permalink
FIX Ensure alterQuery is compatible with silverstripe/fulltextsearch …
Browse files Browse the repository at this point in the history
…<3.3
  • Loading branch information
robbieaverill committed Aug 1, 2018
1 parent fc40484 commit 8927721
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Search/FluentSearchVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace TractorCow\Fluent\Search;

use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\ORM\DataObject;
use TractorCow\Fluent\Extension\FluentExtension;
use TractorCow\Fluent\State\FluentState;
use TractorCow\Fluent\Model\Locale;
use SilverStripe\ORM\DataObject;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
use TractorCow\Fluent\State\FluentState;

if (!class_exists(SearchVariant::class)) {
return;
Expand Down Expand Up @@ -47,7 +47,9 @@ public function activateState($state)
public function alterQuery($query, $index)
{
if (FluentState::singleton()->getIsFrontend() && Locale::getCached()->count()) {
$query->addFilter('_locale', [
// Backwards compatibility for silverstripe/fulltextsearch 3.2/3.3
$method = method_exists($query, 'addFilter') ? 'addFilter' : 'filter';
$query->$method('_locale', [
$this->currentState(),
SearchQuery::$missing
]);
Expand Down

0 comments on commit 8927721

Please sign in to comment.