From ee6de22014e5616e34188f209545d0373975cb17 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sun, 3 May 2015 12:07:15 +0930 Subject: [PATCH] Add event to modify user search --- .../Events/DiscussionSearchWillBePerformed.php | 16 ++++++++++++++++ ...rformed.php => UserSearchWillBePerformed.php} | 6 +++--- .../Search/Discussions/DiscussionSearcher.php | 6 +++--- .../core/src/Core/Search/Users/UserSearcher.php | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 framework/core/src/Core/Events/DiscussionSearchWillBePerformed.php rename framework/core/src/Core/Events/{SearchWillBePerformed.php => UserSearchWillBePerformed.php} (55%) diff --git a/framework/core/src/Core/Events/DiscussionSearchWillBePerformed.php b/framework/core/src/Core/Events/DiscussionSearchWillBePerformed.php new file mode 100644 index 000000000..f36addf52 --- /dev/null +++ b/framework/core/src/Core/Events/DiscussionSearchWillBePerformed.php @@ -0,0 +1,16 @@ +searcher = $searcher; + $this->criteria = $criteria; + } +} diff --git a/framework/core/src/Core/Events/SearchWillBePerformed.php b/framework/core/src/Core/Events/UserSearchWillBePerformed.php similarity index 55% rename from framework/core/src/Core/Events/SearchWillBePerformed.php rename to framework/core/src/Core/Events/UserSearchWillBePerformed.php index 7e141f1bb..731a0f990 100644 --- a/framework/core/src/Core/Events/SearchWillBePerformed.php +++ b/framework/core/src/Core/Events/UserSearchWillBePerformed.php @@ -1,14 +1,14 @@ searcher = $searcher; $this->criteria = $criteria; diff --git a/framework/core/src/Core/Search/Discussions/DiscussionSearcher.php b/framework/core/src/Core/Search/Discussions/DiscussionSearcher.php index c5e5633ec..8c393415e 100644 --- a/framework/core/src/Core/Search/Discussions/DiscussionSearcher.php +++ b/framework/core/src/Core/Search/Discussions/DiscussionSearcher.php @@ -5,11 +5,11 @@ use Flarum\Core\Search\SearcherInterface; use Flarum\Core\Search\GambitManager; use Flarum\Core\Repositories\DiscussionRepositoryInterface; use Flarum\Core\Repositories\PostRepositoryInterface; -use Flarum\Core\Events\SearchWillBePerformed; +use Flarum\Core\Events\DiscussionSearchWillBePerformed; class DiscussionSearcher implements SearcherInterface { - public $query; + protected $query; protected $relevantPosts = []; @@ -72,7 +72,7 @@ class DiscussionSearcher implements SearcherInterface $this->query->take($limit + 1); } - event(new SearchWillBePerformed($this, $criteria)); + event(new DiscussionSearchWillBePerformed($this, $criteria)); $discussions = $this->query->get(); diff --git a/framework/core/src/Core/Search/Users/UserSearcher.php b/framework/core/src/Core/Search/Users/UserSearcher.php index 16ce9e0b0..3265219d6 100644 --- a/framework/core/src/Core/Search/Users/UserSearcher.php +++ b/framework/core/src/Core/Search/Users/UserSearcher.php @@ -60,6 +60,8 @@ class UserSearcher implements SearcherInterface $this->query->take($limit + 1); } + event(new UserSearchWillBePerformed($this, $criteria)); + $users = $this->query->get(); if ($count > 0 && $areMoreResults = $users->count() > $count) {