1 | <?php |
||
34 | class ResultSetReconstitutionProcessor implements SearchResultSetProcessor |
||
35 | { |
||
36 | /** |
||
37 | * @var ObjectManagerInterface |
||
38 | */ |
||
39 | protected $objectManager; |
||
40 | |||
41 | /** |
||
42 | * @return ObjectManagerInterface |
||
43 | */ |
||
44 | 53 | public function getObjectManager() |
|
45 | { |
||
46 | 53 | if ($this->objectManager === null) { |
|
47 | 26 | $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
48 | } |
||
49 | 53 | return $this->objectManager; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param ObjectManagerInterface $objectManager |
||
54 | */ |
||
55 | 27 | public function setObjectManager($objectManager) |
|
56 | { |
||
57 | 27 | $this->objectManager = $objectManager; |
|
58 | 27 | } |
|
59 | |||
60 | |||
61 | /** |
||
62 | * @return FacetRegistry |
||
63 | */ |
||
64 | 53 | protected function getFacetRegistry() |
|
65 | { |
||
66 | 53 | return $this->getObjectManager()->get(FacetRegistry::class); |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * The implementation can be used to influence a SearchResultSet that is |
||
71 | * created and processed in the SearchResultSetService. |
||
72 | * |
||
73 | * @param SearchResultSet $resultSet |
||
74 | * @return SearchResultSet |
||
75 | */ |
||
76 | 65 | public function process(SearchResultSet $resultSet) |
|
91 | |||
92 | /** |
||
93 | * @param SearchResultSet $resultSet |
||
94 | * @return SearchResultSet |
||
95 | */ |
||
96 | 65 | protected function parseResultCount(SearchResultSet $resultSet) |
|
106 | |||
107 | /** |
||
108 | * @param SearchResultSet $resultSet |
||
109 | * @return SearchResultSet |
||
110 | */ |
||
111 | 65 | protected function parseSortingIntoObjects(SearchResultSet $resultSet) |
|
150 | |||
151 | /** |
||
152 | * @param SearchResultSet $resultSet |
||
153 | * @return SearchResultSet |
||
154 | */ |
||
155 | 65 | private function parseSpellCheckingResponseIntoObjects(SearchResultSet $resultSet) |
|
184 | |||
185 | /** |
||
186 | * @param \stdClass $suggestionData |
||
187 | * @param string $suggestedTerm |
||
188 | * @param string $misspelledTerm |
||
189 | * @return Suggestion |
||
190 | */ |
||
191 | 4 | private function createSuggestionFromResponseFragment($suggestionData, $suggestedTerm, $misspelledTerm) |
|
202 | |||
203 | /** |
||
204 | * Parse available facets into objects |
||
205 | * |
||
206 | * @param SearchResultSet $resultSet |
||
207 | * @return SearchResultSet |
||
208 | */ |
||
209 | 65 | private function parseFacetsIntoObjects(SearchResultSet $resultSet) |
|
210 | { |
||
211 | // Make sure we can access the facet configuration |
||
212 | 65 | if (!$resultSet->getUsedSearchRequest() || !$resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()) { |
|
213 | 8 | return $resultSet; |
|
214 | } |
||
215 | |||
216 | // Read the response |
||
217 | 57 | $response = $resultSet->getResponse(); |
|
218 | 57 | if (!is_object($response->facet_counts)) { |
|
219 | 4 | return $resultSet; |
|
220 | } |
||
221 | |||
222 | /** @var FacetRegistry $facetRegistry */ |
||
223 | 53 | $facetRegistry = $this->getFacetRegistry(); |
|
224 | 53 | $facetsConfiguration = $resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()->getSearchFacetingFacets(); |
|
225 | |||
226 | 53 | foreach ($facetsConfiguration as $name => $options) { |
|
227 | 51 | if (!is_array($options)) { |
|
228 | continue; |
||
229 | } |
||
230 | 51 | $facetName = rtrim($name, '.'); |
|
231 | 51 | $type = !empty($options['type']) ? $options['type'] : ''; |
|
232 | |||
233 | 51 | $parser = $facetRegistry->getPackage($type)->getParser(); |
|
234 | 51 | $facet = $parser->parse($resultSet, $facetName, $options); |
|
235 | 51 | if ($facet !== null) { |
|
236 | 51 | $resultSet->addFacet($facet); |
|
237 | } |
||
238 | } |
||
239 | |||
240 | 53 | $this->applyRequirements($resultSet); |
|
241 | |||
242 | 53 | return $resultSet; |
|
243 | } |
||
244 | |||
245 | /** |
||
246 | * @param SearchResultSet $resultSet |
||
247 | */ |
||
248 | 53 | protected function applyRequirements(SearchResultSet $resultSet) |
|
249 | { |
||
250 | 53 | $requirementsService = $this->getRequirementsService(); |
|
251 | 53 | $facets = $resultSet->getFacets(); |
|
252 | 53 | foreach ($facets as $facet) { |
|
253 | /** @var $facet AbstractFacet */ |
||
254 | 49 | $requirementsMet = $requirementsService->getAllRequirementsMet($facet); |
|
255 | 49 | $facet->setAllRequirementsMet($requirementsMet); |
|
256 | } |
||
257 | 53 | } |
|
258 | |||
259 | /** |
||
260 | * @return RequirementsService |
||
261 | */ |
||
262 | 53 | protected function getRequirementsService() |
|
266 | } |
||
267 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.