diff options
Diffstat (limited to 'lib/Service/SearchService.php')
-rw-r--r-- | lib/Service/SearchService.php | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/Service/SearchService.php b/lib/Service/SearchService.php index 5552b5c..3dfa85e 100644 --- a/lib/Service/SearchService.php +++ b/lib/Service/SearchService.php @@ -32,17 +32,20 @@ use OC\User\NoUserException; use OCA\Circles\Api\v1\Circles; use OCA\FullTextSearch\Exceptions\EmptySearchException; use OCA\FullTextSearch\Exceptions\ProviderDoesNotExistException; -use OCA\FullTextSearch\IFullTextSearchPlatform; -use OCA\FullTextSearch\IFullTextSearchProvider; -use OCA\FullTextSearch\Model\DocumentAccess; use OCA\FullTextSearch\Model\SearchRequest; use OCA\FullTextSearch\Model\SearchResult; +use OCP\FullTextSearch\IFullTextSearchPlatform; +use OCP\FullTextSearch\IFullTextSearchProvider; +use OCP\FullTextSearch\Model\DocumentAccess; +use OCP\FullTextSearch\Model\ISearchRequest; +use OCP\FullTextSearch\Model\ISearchResult; +use OCP\FullTextSearch\Service\ISearchService; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; -class SearchService { +class SearchService implements ISearchService { /** @var string */ private $userId; @@ -99,18 +102,29 @@ class SearchService { /** + * @param array $request + * + * @return ISearchRequest + */ + public function generateSearchRequest(array $request): ISearchRequest { + return SearchRequest::fromArray($request); + } + + + /** * @param string $userId - * @param SearchRequest $request + * @param ISearchRequest $request * + * @return ISearchResult[] * @throws EmptySearchException * @throws Exception * @throws ProviderDoesNotExistException */ - public function search($userId, SearchRequest $request) { + public function search(string $userId, ISearchRequest $request): array { $this->searchRequestCannotBeEmpty($request); - if ($userId === null) { + if ($userId === '') { $userId = $this->userId; } @@ -119,6 +133,7 @@ class SearchService { throw new NoUserException('User does not exist'); } + /** @var $request SearchRequest */ $request->setAuthor($user->getUID()); $request->cleanSearch(); @@ -139,11 +154,11 @@ class SearchService { /** - * @param SearchRequest $request + * @param ISearchRequest $request * * @throws EmptySearchException */ - private function searchRequestCannotBeEmpty(SearchRequest $request) { + private function searchRequestCannotBeEmpty(ISearchRequest $request) { if ($request === null || strlen($request->getSearch()) < 1) { throw new EmptySearchException('search cannot be empty'); } @@ -156,7 +171,7 @@ class SearchService { * @param IFullTextSearchProvider[] $providers * @param SearchRequest $request * - * @return SearchResult[] + * @return ISearchResult[] */ private function searchFromProviders( IFullTextSearchPlatform $platform, $providers, DocumentAccess $access, |