| @@ 19-142 (lines=124) @@ | ||
| 16 | /** |
|
| 17 | * SearchService class. |
|
| 18 | */ |
|
| 19 | class SearchService implements SearchServiceInterface |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * Aggregated service. |
|
| 23 | * |
|
| 24 | * @var \eZ\Publish\API\Repository\SearchService |
|
| 25 | */ |
|
| 26 | protected $service; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * SignalDispatcher. |
|
| 30 | * |
|
| 31 | * @var \eZ\Publish\Core\SignalSlot\SignalDispatcher |
|
| 32 | */ |
|
| 33 | protected $signalDispatcher; |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Constructor. |
|
| 37 | * |
|
| 38 | * Construct service object from aggregated service and signal |
|
| 39 | * dispatcher |
|
| 40 | * |
|
| 41 | * @param \eZ\Publish\API\Repository\SearchService $service |
|
| 42 | * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher |
|
| 43 | */ |
|
| 44 | public function __construct(SearchServiceInterface $service, SignalDispatcher $signalDispatcher) |
|
| 45 | { |
|
| 46 | $this->service = $service; |
|
| 47 | $this->signalDispatcher = $signalDispatcher; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Finds content objects for the given query. |
|
| 52 | * |
|
| 53 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid |
|
| 54 | * |
|
| 55 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
|
| 56 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
|
| 57 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
|
| 58 | * @param bool $filterOnUserPermissions if true only the objects which the user is allowed to read are returned. |
|
| 59 | * |
|
| 60 | * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
|
| 61 | */ |
|
| 62 | public function findContent(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 63 | { |
|
| 64 | return $this->service->findContent($query, $languageFilter, $filterOnUserPermissions); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Finds contentInfo objects for the given query. |
|
| 69 | * |
|
| 70 | * @see SearchServiceInterface::findContentInfo() |
|
| 71 | * |
|
| 72 | * @since 5.4.5 |
|
| 73 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid |
|
| 74 | * |
|
| 75 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
|
| 76 | * @param array $languageFilter - a map of filters for the returned fields. |
|
| 77 | * Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code> |
|
| 78 | * useAlwaysAvailable defaults to true to avoid exceptions on missing translations. |
|
| 79 | * @param bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned. |
|
| 80 | * |
|
| 81 | * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
|
| 82 | */ |
|
| 83 | public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 84 | { |
|
| 85 | return $this->service->findContentInfo($query, $languageFilter, $filterOnUserPermissions); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Performs a query for a single content object. |
|
| 90 | * |
|
| 91 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions |
|
| 92 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if criterion is not valid |
|
| 93 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is more than than one result matching the criterions |
|
| 94 | * |
|
| 95 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter |
|
| 96 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
|
| 97 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
|
| 98 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
|
| 99 | * |
|
| 100 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 101 | */ |
|
| 102 | public function findSingle(Criterion $filter, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 103 | { |
|
| 104 | return $this->service->findSingle($filter, $languageFilter, $filterOnUserPermissions); |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| 108 | * Suggests a list of values for the given prefix. |
|
| 109 | * |
|
| 110 | * @param string $prefix |
|
| 111 | * @param string[] $fieldPaths |
|
| 112 | * @param int $limit |
|
| 113 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter |
|
| 114 | */ |
|
| 115 | public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $filter = null) |
|
| 116 | { |
|
| 117 | return $this->service->suggest($prefix, $fieldPaths, $limit, $filter); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * Finds Locations for the given query. |
|
| 122 | * |
|
| 123 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid |
|
| 124 | * |
|
| 125 | * @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query |
|
| 126 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
|
| 127 | * Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code> |
|
| 128 | * useAlwaysAvailable defaults to true to avoid exceptions on missing translations |
|
| 129 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
|
| 130 | * |
|
| 131 | * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
|
| 132 | */ |
|
| 133 | public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 134 | { |
|
| 135 | return $this->service->findLocations($query, $languageFilter, $filterOnUserPermissions); |
|
| 136 | } |
|
| 137 | ||
| 138 | public function supports($capabilityFlag) |
|
| 139 | { |
|
| 140 | return $this->service->supports($capabilityFlag); |
|
| 141 | } |
|
| 142 | } |
|
| 143 | ||
| @@ 16-73 (lines=58) @@ | ||
| 13 | use eZ\Publish\API\Repository\Values\Content\Query; |
|
| 14 | use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
|
| 15 | ||
| 16 | abstract class SearchServiceDecorator implements SearchService |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @var \eZ\Publish\API\Repository\SearchService |
|
| 20 | */ |
|
| 21 | protected $innerService; |
|
| 22 | ||
| 23 | public function __construct(SearchService $innerService) |
|
| 24 | { |
|
| 25 | $this->innerService = $innerService; |
|
| 26 | } |
|
| 27 | ||
| 28 | public function findContent( |
|
| 29 | Query $query, |
|
| 30 | array $languageFilter = [], |
|
| 31 | $filterOnUserPermissions = true |
|
| 32 | ) { |
|
| 33 | return $this->innerService->findContent($query, $languageFilter, $filterOnUserPermissions); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function findContentInfo( |
|
| 37 | Query $query, |
|
| 38 | array $languageFilter = [], |
|
| 39 | $filterOnUserPermissions = true |
|
| 40 | ) { |
|
| 41 | return $this->innerService->findContentInfo($query, $languageFilter, $filterOnUserPermissions); |
|
| 42 | } |
|
| 43 | ||
| 44 | public function findSingle( |
|
| 45 | Criterion $filter, |
|
| 46 | array $languageFilter = [], |
|
| 47 | $filterOnUserPermissions = true |
|
| 48 | ) { |
|
| 49 | return $this->innerService->findSingle($filter, $languageFilter, $filterOnUserPermissions); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function suggest( |
|
| 53 | $prefix, |
|
| 54 | $fieldPaths = [], |
|
| 55 | $limit = 10, |
|
| 56 | Criterion $filter = null |
|
| 57 | ) { |
|
| 58 | return $this->innerService->suggest($prefix, $fieldPaths, $limit, $filter); |
|
| 59 | } |
|
| 60 | ||
| 61 | public function findLocations( |
|
| 62 | LocationQuery $query, |
|
| 63 | array $languageFilter = [], |
|
| 64 | $filterOnUserPermissions = true |
|
| 65 | ) { |
|
| 66 | return $this->innerService->findLocations($query, $languageFilter, $filterOnUserPermissions); |
|
| 67 | } |
|
| 68 | ||
| 69 | public function supports($capabilityFlag) |
|
| 70 | { |
|
| 71 | return $this->innerService->supports($capabilityFlag); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||