1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* SearchService class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\SignalSlot; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\SearchService as SearchServiceInterface; |
12
|
|
|
use eZ\Publish\API\Repository\SearchServiceSortClause as SearchServiceSortClauseInterface; |
13
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location; |
14
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query; |
15
|
|
|
use eZ\Publish\API\Repository\Values\Content\LocationQuery; |
16
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* SearchService class. |
20
|
|
|
*/ |
21
|
|
|
class SearchService implements SearchServiceInterface, SearchServiceSortClauseInterface |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Aggregated service. |
25
|
|
|
* |
26
|
|
|
* @var \eZ\Publish\API\Repository\SearchService |
27
|
|
|
*/ |
28
|
|
|
protected $service; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* SignalDispatcher. |
32
|
|
|
* |
33
|
|
|
* @var \eZ\Publish\Core\SignalSlot\SignalDispatcher |
34
|
|
|
*/ |
35
|
|
|
protected $signalDispatcher; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Constructor. |
39
|
|
|
* |
40
|
|
|
* Construct service object from aggregated service and signal |
41
|
|
|
* dispatcher |
42
|
|
|
* |
43
|
|
|
* @param \eZ\Publish\API\Repository\SearchService $service |
44
|
|
|
* @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher |
45
|
|
|
*/ |
46
|
|
|
public function __construct(SearchServiceInterface $service, SignalDispatcher $signalDispatcher) |
47
|
|
|
{ |
48
|
|
|
$this->service = $service; |
49
|
|
|
$this->signalDispatcher = $signalDispatcher; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Finds content objects for the given query. |
54
|
|
|
* |
55
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid |
56
|
|
|
* |
57
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Query $query |
58
|
|
|
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
59
|
|
|
* Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
60
|
|
|
* @param bool $filterOnUserPermissions if true only the objects which the user is allowed to read are returned. |
61
|
|
|
* |
62
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
63
|
|
|
*/ |
64
|
|
|
public function findContent(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
65
|
|
|
{ |
66
|
|
|
return $this->service->findContent($query, $languageFilter, $filterOnUserPermissions); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Finds contentInfo objects for the given query. |
71
|
|
|
* |
72
|
|
|
* @see SearchServiceInterface::findContentInfo() |
73
|
|
|
* |
74
|
|
|
* @since 5.4.5 |
75
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid |
76
|
|
|
* |
77
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Query $query |
78
|
|
|
* @param array $languageFilter - a map of filters for the returned fields. |
79
|
|
|
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code> |
80
|
|
|
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations. |
81
|
|
|
* @param bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned. |
82
|
|
|
* |
83
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
84
|
|
|
*/ |
85
|
|
|
public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
86
|
|
|
{ |
87
|
|
|
return $this->service->findContentInfo($query, $languageFilter, $filterOnUserPermissions); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Performs a query for a single content object. |
92
|
|
|
* |
93
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions |
94
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if criterion is not valid |
95
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is more than than one result matching the criterions |
96
|
|
|
* |
97
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter |
98
|
|
|
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
99
|
|
|
* Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
100
|
|
|
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
101
|
|
|
* |
102
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Content |
103
|
|
|
*/ |
104
|
|
|
public function findSingle(Criterion $filter, array $languageFilter = array(), $filterOnUserPermissions = true) |
105
|
|
|
{ |
106
|
|
|
return $this->service->findSingle($filter, $languageFilter, $filterOnUserPermissions); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Suggests a list of values for the given prefix. |
111
|
|
|
* |
112
|
|
|
* @param string $prefix |
113
|
|
|
* @param string[] $fieldPaths |
114
|
|
|
* @param int $limit |
115
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter |
116
|
|
|
*/ |
117
|
|
|
public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $filter = null) |
118
|
|
|
{ |
119
|
|
|
return $this->service->suggest($prefix, $fieldPaths, $limit, $filter); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Finds Locations for the given query. |
124
|
|
|
* |
125
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid |
126
|
|
|
* |
127
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query |
128
|
|
|
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
129
|
|
|
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code> |
130
|
|
|
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations |
131
|
|
|
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
132
|
|
|
* |
133
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
134
|
|
|
*/ |
135
|
|
|
public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
136
|
|
|
{ |
137
|
|
|
return $this->service->findLocations($query, $languageFilter, $filterOnUserPermissions); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Get SortClause built from $location's sort options. |
142
|
|
|
* |
143
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Location $location |
144
|
|
|
* |
145
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Query\SortClause |
146
|
|
|
*/ |
147
|
|
|
public function getSortClauseFromLocation(Location $location) |
148
|
|
|
{ |
149
|
|
|
return $this->service->getSortClauseFromLocation($location); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.