Extract Flarum\Search namespace

This commit is contained in:
Franz Liedke 2017-06-24 13:59:50 +02:00
parent 4fb38d6458
commit 11bf3e34b7
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
26 changed files with 57 additions and 57 deletions

View File

@ -13,7 +13,7 @@ namespace Flarum\Api\Controller;
use Flarum\Api\UrlGenerator; use Flarum\Api\UrlGenerator;
use Flarum\Discussion\Search\DiscussionSearcher; use Flarum\Discussion\Search\DiscussionSearcher;
use Flarum\Core\Search\SearchCriteria; use Flarum\Search\SearchCriteria;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;

View File

@ -13,7 +13,7 @@ namespace Flarum\Api\Controller;
use Flarum\Api\UrlGenerator; use Flarum\Api\UrlGenerator;
use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\Exception\PermissionDeniedException;
use Flarum\Core\Search\SearchCriteria; use Flarum\Search\SearchCriteria;
use Flarum\Core\User\Search\UserSearcher; use Flarum\Core\User\Search\UserSearcher;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;

View File

@ -41,7 +41,7 @@ class CoreServiceProvider extends AbstractServiceProvider
$this->registerAvatarsFilesystem(); $this->registerAvatarsFilesystem();
$this->app->register('Flarum\Core\Notification\NotificationServiceProvider'); $this->app->register('Flarum\Core\Notification\NotificationServiceProvider');
$this->app->register('Flarum\Core\Search\SearchServiceProvider'); $this->app->register('Flarum\Search\SearchServiceProvider');
$this->app->register('Flarum\Formatter\FormatterServiceProvider'); $this->app->register('Flarum\Formatter\FormatterServiceProvider');
} }

View File

@ -11,7 +11,7 @@
namespace Flarum\Discussion\Search; namespace Flarum\Discussion\Search;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
/** /**
* An object which represents the internal state of a search for discussions: * An object which represents the internal state of a search for discussions:

View File

@ -15,10 +15,10 @@ use Flarum\Discussion\Discussion;
use Flarum\Discussion\DiscussionRepository; use Flarum\Discussion\DiscussionRepository;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use Flarum\Post\PostRepository; use Flarum\Post\PostRepository;
use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Search\ApplySearchParametersTrait;
use Flarum\Core\Search\GambitManager; use Flarum\Search\GambitManager;
use Flarum\Core\Search\SearchCriteria; use Flarum\Search\SearchCriteria;
use Flarum\Core\Search\SearchResults; use Flarum\Search\SearchResults;
use Flarum\Event\ConfigureDiscussionSearch; use Flarum\Event\ConfigureDiscussionSearch;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
@ -31,7 +31,7 @@ class DiscussionSearcher
use ApplySearchParametersTrait; use ApplySearchParametersTrait;
/** /**
* @var GambitManager * @var \Flarum\Search\GambitManager
*/ */
protected $gambits; protected $gambits;
@ -46,7 +46,7 @@ class DiscussionSearcher
protected $posts; protected $posts;
/** /**
* @param GambitManager $gambits * @param \Flarum\Search\GambitManager $gambits
* @param DiscussionRepository $discussions * @param DiscussionRepository $discussions
* @param PostRepository $posts * @param PostRepository $posts
*/ */
@ -61,13 +61,13 @@ class DiscussionSearcher
} }
/** /**
* @param SearchCriteria $criteria * @param \Flarum\Search\SearchCriteria $criteria
* @param int|null $limit * @param int|null $limit
* @param int $offset * @param int $offset
* @param array $load An array of relationships to load on the results. * @param array $load An array of relationships to load on the results.
* @return SearchResults * @return \Flarum\Search\SearchResults
*/ */
public function search(SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) public function search(\Flarum\Search\SearchCriteria $criteria, $limit = null, $offset = 0, array $load = [])
{ {
$actor = $criteria->actor; $actor = $criteria->actor;
@ -110,7 +110,7 @@ class DiscussionSearcher
Discussion::setStateUser($actor); Discussion::setStateUser($actor);
$discussions->load($load); $discussions->load($load);
return new SearchResults($discussions, $areMoreResults); return new \Flarum\Search\SearchResults($discussions, $areMoreResults);
} }
/** /**

View File

@ -12,8 +12,8 @@
namespace Flarum\Discussion\Search\Gambit; namespace Flarum\Discussion\Search\Gambit;
use Flarum\User\UserRepository; use Flarum\User\UserRepository;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use LogicException; use LogicException;

View File

@ -11,8 +11,8 @@
namespace Flarum\Discussion\Search\Gambit; namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use LogicException; use LogicException;

View File

@ -11,10 +11,10 @@
namespace Flarum\Discussion\Search\Gambit; namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use Flarum\Discussion\Search\Fulltext\DriverInterface; use Flarum\Discussion\Search\Fulltext\DriverInterface;
use Flarum\Core\Search\GambitInterface; use Flarum\Search\GambitInterface;
use LogicException; use LogicException;
class FulltextGambit implements GambitInterface class FulltextGambit implements GambitInterface

View File

@ -11,8 +11,8 @@
namespace Flarum\Discussion\Search\Gambit; namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use LogicException; use LogicException;

View File

@ -12,8 +12,8 @@
namespace Flarum\Discussion\Search\Gambit; namespace Flarum\Discussion\Search\Gambit;
use Flarum\Discussion\DiscussionRepository; use Flarum\Discussion\DiscussionRepository;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use LogicException; use LogicException;

View File

@ -11,7 +11,7 @@
namespace Flarum\Event; namespace Flarum\Event;
use Flarum\Core\Search\GambitManager; use Flarum\Search\GambitManager;
abstract class AbstractConfigureGambits abstract class AbstractConfigureGambits
{ {
@ -21,7 +21,7 @@ abstract class AbstractConfigureGambits
public $gambits; public $gambits;
/** /**
* @param GambitManager $gambits * @param \Flarum\Search\GambitManager $gambits
*/ */
public function __construct(GambitManager $gambits) public function __construct(GambitManager $gambits)
{ {

View File

@ -12,7 +12,7 @@
namespace Flarum\Event; namespace Flarum\Event;
use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\DiscussionSearch;
use Flarum\Core\Search\SearchCriteria; use Flarum\Search\SearchCriteria;
class ConfigureDiscussionSearch class ConfigureDiscussionSearch
{ {
@ -22,13 +22,13 @@ class ConfigureDiscussionSearch
public $search; public $search;
/** /**
* @var SearchCriteria * @var \Flarum\Search\SearchCriteria
*/ */
public $criteria; public $criteria;
/** /**
* @param DiscussionSearch $search * @param DiscussionSearch $search
* @param SearchCriteria $criteria * @param \Flarum\Search\SearchCriteria $criteria
*/ */
public function __construct(DiscussionSearch $search, SearchCriteria $criteria) public function __construct(DiscussionSearch $search, SearchCriteria $criteria)
{ {

View File

@ -11,7 +11,7 @@
namespace Flarum\Event; namespace Flarum\Event;
use Flarum\Core\Search\SearchCriteria; use Flarum\Search\SearchCriteria;
use Flarum\Core\User\Search\UserSearch; use Flarum\Core\User\Search\UserSearch;
class ConfigureUserSearch class ConfigureUserSearch

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
abstract class AbstractRegexGambit implements GambitInterface abstract class AbstractRegexGambit implements GambitInterface
{ {

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Builder;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
trait ApplySearchParametersTrait trait ApplySearchParametersTrait
{ {

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
interface GambitInterface interface GambitInterface
{ {

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;
use LogicException; use LogicException;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
use Flarum\User\User; use Flarum\User\User;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Search; namespace Flarum\Search;
use Flarum\Event\ConfigureDiscussionGambits; use Flarum\Event\ConfigureDiscussionGambits;
use Flarum\Event\ConfigureUserGambits; use Flarum\Event\ConfigureUserGambits;
@ -38,7 +38,7 @@ class SearchServiceProvider extends AbstractServiceProvider
public function registerUserGambits() public function registerUserGambits()
{ {
$this->app->when('Flarum\Core\User\Search\UserSearcher') $this->app->when('Flarum\Core\User\Search\UserSearcher')
->needs('Flarum\Core\Search\GambitManager') ->needs('Flarum\Search\GambitManager')
->give(function (Container $app) { ->give(function (Container $app) {
$gambits = new GambitManager($app); $gambits = new GambitManager($app);
@ -57,7 +57,7 @@ class SearchServiceProvider extends AbstractServiceProvider
public function registerDiscussionGambits() public function registerDiscussionGambits()
{ {
$this->app->when('Flarum\Discussion\Search\DiscussionSearcher') $this->app->when('Flarum\Discussion\Search\DiscussionSearcher')
->needs('Flarum\Core\Search\GambitManager') ->needs('Flarum\Search\GambitManager')
->give(function (Container $app) { ->give(function (Container $app) {
$gambits = new GambitManager($app); $gambits = new GambitManager($app);

View File

@ -12,8 +12,8 @@
namespace Flarum\Core\User\Search\Gambit; namespace Flarum\Core\User\Search\Gambit;
use Flarum\User\UserRepository; use Flarum\User\UserRepository;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Core\User\Search\UserSearch; use Flarum\Core\User\Search\UserSearch;
use LogicException; use LogicException;

View File

@ -12,8 +12,8 @@
namespace Flarum\Core\User\Search\Gambit; namespace Flarum\Core\User\Search\Gambit;
use Flarum\User\UserRepository; use Flarum\User\UserRepository;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Core\Search\GambitInterface; use Flarum\Search\GambitInterface;
class FulltextGambit implements GambitInterface class FulltextGambit implements GambitInterface
{ {

View File

@ -12,8 +12,8 @@
namespace Flarum\Core\User\Search\Gambit; namespace Flarum\Core\User\Search\Gambit;
use Flarum\Core\Repository\GroupRepository; use Flarum\Core\Repository\GroupRepository;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
use Flarum\Core\User\Search\UserSearch; use Flarum\Core\User\Search\UserSearch;
use LogicException; use LogicException;

View File

@ -11,7 +11,7 @@
namespace Flarum\Core\User\Search; namespace Flarum\Core\User\Search;
use Flarum\Core\Search\AbstractSearch; use Flarum\Search\AbstractSearch;
class UserSearch extends AbstractSearch class UserSearch extends AbstractSearch
{ {

View File

@ -13,10 +13,10 @@ namespace Flarum\Core\User\Search;
use Flarum\Core\User\Search\UserSearch; use Flarum\Core\User\Search\UserSearch;
use Flarum\User\UserRepository; use Flarum\User\UserRepository;
use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Search\ApplySearchParametersTrait;
use Flarum\Core\Search\GambitManager; use Flarum\Search\GambitManager;
use Flarum\Core\Search\SearchCriteria; use Flarum\Search\SearchCriteria;
use Flarum\Core\Search\SearchResults; use Flarum\Search\SearchResults;
use Flarum\Event\ConfigureUserSearch; use Flarum\Event\ConfigureUserSearch;
/** /**
@ -28,7 +28,7 @@ class UserSearcher
use ApplySearchParametersTrait; use ApplySearchParametersTrait;
/** /**
* @var GambitManager * @var \Flarum\Search\GambitManager
*/ */
protected $gambits; protected $gambits;
@ -38,10 +38,10 @@ class UserSearcher
protected $users; protected $users;
/** /**
* @param GambitManager $gambits * @param \Flarum\Search\GambitManager $gambits
* @param \Flarum\User\UserRepository $users * @param \Flarum\User\UserRepository $users
*/ */
public function __construct(GambitManager $gambits, UserRepository $users) public function __construct(\Flarum\Search\GambitManager $gambits, UserRepository $users)
{ {
$this->gambits = $gambits; $this->gambits = $gambits;
$this->users = $users; $this->users = $users;
@ -52,9 +52,9 @@ class UserSearcher
* @param int|null $limit * @param int|null $limit
* @param int $offset * @param int $offset
* @param array $load An array of relationships to load on the results. * @param array $load An array of relationships to load on the results.
* @return SearchResults * @return \Flarum\Search\SearchResults
*/ */
public function search(SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) public function search(\Flarum\Search\SearchCriteria $criteria, $limit = null, $offset = 0, array $load = [])
{ {
$actor = $criteria->actor; $actor = $criteria->actor;
@ -83,6 +83,6 @@ class UserSearcher
$users->load($load); $users->load($load);
return new SearchResults($users, $areMoreResults); return new \Flarum\Search\SearchResults($users, $areMoreResults);
} }
} }