vendor/ezsystems/ezplatform-kernel/eZ/Publish/Core/Repository/SiteAccessAware/SearchService.php line 22

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace eZ\Publish\Core\Repository\SiteAccessAware;
  8. use eZ\Publish\API\Repository\SearchService as SearchServiceInterface;
  9. use eZ\Publish\API\Repository\Values\Content\Content;
  10. use eZ\Publish\API\Repository\Values\Content\Query;
  11. use eZ\Publish\API\Repository\Values\Content\LocationQuery;
  12. use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
  13. use eZ\Publish\API\Repository\Values\Content\Search\SearchResult;
  14. use eZ\Publish\API\Repository\LanguageResolver;
  15. /**
  16.  * SiteAccess aware implementation of SearchService injecting languages where needed.
  17.  */
  18. class SearchService implements SearchServiceInterface
  19. {
  20.     /** @var \eZ\Publish\API\Repository\SearchService */
  21.     protected $service;
  22.     /** @var \eZ\Publish\API\Repository\LanguageResolver */
  23.     protected $languageResolver;
  24.     /**
  25.      * Construct service object from aggregated service and LanguageResolver.
  26.      *
  27.      * @param \eZ\Publish\API\Repository\SearchService $service
  28.      * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
  29.      */
  30.     public function __construct(
  31.         SearchServiceInterface $service,
  32.         LanguageResolver $languageResolver
  33.     ) {
  34.         $this->service $service;
  35.         $this->languageResolver $languageResolver;
  36.     }
  37.     public function findContent(Query $query, array $languageFilter = [], bool $filterOnUserPermissions true): SearchResult
  38.     {
  39.         $languageFilter['languages'] = $this->languageResolver->getPrioritizedLanguages(
  40.             $languageFilter['languages'] ?? null
  41.         );
  42.         $languageFilter['useAlwaysAvailable'] = $this->languageResolver->getUseAlwaysAvailable(
  43.             $languageFilter['useAlwaysAvailable'] ?? null
  44.         );
  45.         return $this->service->findContent($query$languageFilter$filterOnUserPermissions);
  46.     }
  47.     public function findContentInfo(Query $query, array $languageFilter = [], bool $filterOnUserPermissions true): SearchResult
  48.     {
  49.         $languageFilter['languages'] = $this->languageResolver->getPrioritizedLanguages(
  50.             $languageFilter['languages'] ?? null
  51.         );
  52.         $languageFilter['useAlwaysAvailable'] = $this->languageResolver->getUseAlwaysAvailable(
  53.             $languageFilter['useAlwaysAvailable'] ?? null
  54.         );
  55.         return $this->service->findContentInfo($query$languageFilter$filterOnUserPermissions);
  56.     }
  57.     public function findSingle(Criterion $filter, array $languageFilter = [], bool $filterOnUserPermissions true): Content
  58.     {
  59.         $languageFilter['languages'] = $this->languageResolver->getPrioritizedLanguages(
  60.             $languageFilter['languages'] ?? null
  61.         );
  62.         $languageFilter['useAlwaysAvailable'] = $this->languageResolver->getUseAlwaysAvailable(
  63.             $languageFilter['useAlwaysAvailable'] ?? null
  64.         );
  65.         return $this->service->findSingle($filter$languageFilter$filterOnUserPermissions);
  66.     }
  67.     public function suggest(string $prefix, array $fieldPaths = [], int $limit 10Criterion $filter null)
  68.     {
  69.         return $this->service->suggest($prefix$fieldPaths$limit$filter);
  70.     }
  71.     public function findLocations(LocationQuery $query, array $languageFilter = [], bool $filterOnUserPermissions true): SearchResult
  72.     {
  73.         $languageFilter['languages'] = $this->languageResolver->getPrioritizedLanguages(
  74.             $languageFilter['languages'] ?? null
  75.         );
  76.         $languageFilter['useAlwaysAvailable'] = $this->languageResolver->getUseAlwaysAvailable(
  77.             $languageFilter['useAlwaysAvailable'] ?? null
  78.         );
  79.         return $this->service->findLocations($query$languageFilter$filterOnUserPermissions);
  80.     }
  81.     public function supports(int $capabilityFlag): bool
  82.     {
  83.         return $this->service->supports($capabilityFlag);
  84.     }
  85. }