mirror of
https://github.com/flarum/core.git
synced 2025-06-06 22:55:11 +02:00
Add event to modify user search
This commit is contained in:
parent
d966c9831a
commit
f03f046efe
16
src/Core/Events/DiscussionSearchWillBePerformed.php
Normal file
16
src/Core/Events/DiscussionSearchWillBePerformed.php
Normal file
@ -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;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Search\SearcherInterface;
|
use Flarum\Core\Search\Users\UserSearcher;
|
||||||
|
|
||||||
class SearchWillBePerformed
|
class UserSearchWillBePerformed
|
||||||
{
|
{
|
||||||
public $searcher;
|
public $searcher;
|
||||||
|
|
||||||
public $criteria;
|
public $criteria;
|
||||||
|
|
||||||
public function __construct(SearcherInterface $searcher, $criteria)
|
public function __construct(UserSearcher $searcher, $criteria)
|
||||||
{
|
{
|
||||||
$this->searcher = $searcher;
|
$this->searcher = $searcher;
|
||||||
$this->criteria = $criteria;
|
$this->criteria = $criteria;
|
@ -5,11 +5,11 @@ use Flarum\Core\Search\SearcherInterface;
|
|||||||
use Flarum\Core\Search\GambitManager;
|
use Flarum\Core\Search\GambitManager;
|
||||||
use Flarum\Core\Repositories\DiscussionRepositoryInterface;
|
use Flarum\Core\Repositories\DiscussionRepositoryInterface;
|
||||||
use Flarum\Core\Repositories\PostRepositoryInterface;
|
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||||
use Flarum\Core\Events\SearchWillBePerformed;
|
use Flarum\Core\Events\DiscussionSearchWillBePerformed;
|
||||||
|
|
||||||
class DiscussionSearcher implements SearcherInterface
|
class DiscussionSearcher implements SearcherInterface
|
||||||
{
|
{
|
||||||
public $query;
|
protected $query;
|
||||||
|
|
||||||
protected $relevantPosts = [];
|
protected $relevantPosts = [];
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class DiscussionSearcher implements SearcherInterface
|
|||||||
$this->query->take($limit + 1);
|
$this->query->take($limit + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
event(new SearchWillBePerformed($this, $criteria));
|
event(new DiscussionSearchWillBePerformed($this, $criteria));
|
||||||
|
|
||||||
$discussions = $this->query->get();
|
$discussions = $this->query->get();
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ class UserSearcher implements SearcherInterface
|
|||||||
$this->query->take($limit + 1);
|
$this->query->take($limit + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event(new UserSearchWillBePerformed($this, $criteria));
|
||||||
|
|
||||||
$users = $this->query->get();
|
$users = $this->query->get();
|
||||||
|
|
||||||
if ($count > 0 && $areMoreResults = $users->count() > $count) {
|
if ($count > 0 && $areMoreResults = $users->count() > $count) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user