mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 07:42:48 +08:00
Add event to modify user search
This commit is contained in:
parent
5ffdd8227c
commit
ee6de22014
|
@ -0,0 +1,16 @@
|
|||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Search\Discussions\DiscussionSearcher;
|
||||
|
||||
class DiscussionSearchWillBePerformed
|
||||
{
|
||||
public $searcher;
|
||||
|
||||
public $criteria;
|
||||
|
||||
public function __construct(DiscussionSearcher $searcher, $criteria)
|
||||
{
|
||||
$this->searcher = $searcher;
|
||||
$this->criteria = $criteria;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Search\SearcherInterface;
|
||||
use Flarum\Core\Search\Users\UserSearcher;
|
||||
|
||||
class SearchWillBePerformed
|
||||
class UserSearchWillBePerformed
|
||||
{
|
||||
public $searcher;
|
||||
|
||||
public $criteria;
|
||||
|
||||
public function __construct(SearcherInterface $searcher, $criteria)
|
||||
public function __construct(UserSearcher $searcher, $criteria)
|
||||
{
|
||||
$this->searcher = $searcher;
|
||||
$this->criteria = $criteria;
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user