Skip to content

Commit

Permalink
Merge pull request #451 from creative-commoners/pulls/4.1/search-compat
Browse files Browse the repository at this point in the history
FIX Ensure alterQuery is compatible with silverstripe/fulltextsearch <3.3
  • Loading branch information
ScopeyNZ authored Aug 1, 2018
2 parents fc40484 + 8927721 commit ce9a159
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 ce9a159

Please sign in to comment.