1 | <?php |
||
53 | class ElasticSearchPlatform implements IFullTextSearchPlatform { |
||
54 | |||
55 | /** @var ConfigService */ |
||
56 | private $configService; |
||
57 | |||
58 | /** @var IndexService */ |
||
59 | private $indexService; |
||
60 | |||
61 | /** @var SearchService */ |
||
62 | private $searchService; |
||
63 | |||
64 | /** @var MiscService */ |
||
65 | private $miscService; |
||
66 | |||
67 | /** @var Client */ |
||
68 | private $client; |
||
69 | |||
70 | /** @var Runner */ |
||
71 | private $runner; |
||
72 | |||
73 | |||
74 | /** |
||
75 | * return a unique Id of the platform. |
||
76 | */ |
||
77 | public function getId() { |
||
80 | |||
81 | /** |
||
82 | * return a unique Id of the platform. |
||
83 | */ |
||
84 | public function getName() { |
||
87 | |||
88 | |||
89 | public function getClient() { |
||
92 | |||
93 | |||
94 | /** |
||
95 | * @param Runner $runner |
||
96 | */ |
||
97 | public function setRunner(Runner $runner) { |
||
100 | |||
101 | /** |
||
102 | * @param $action |
||
103 | * |
||
104 | * @throws InterruptException |
||
105 | * @throws TickDoesNotExistException |
||
106 | */ |
||
107 | private function updateRunner($action) { |
||
114 | |||
115 | |||
116 | /** |
||
117 | * @param $line |
||
118 | */ |
||
119 | private function outputRunner($line) { |
||
126 | |||
127 | |||
128 | /** |
||
129 | * Called when loading the platform. |
||
130 | * |
||
131 | * Loading some container and connect to ElasticSearch. |
||
132 | * |
||
133 | * @throws ConfigurationException |
||
134 | * @throws QueryException |
||
135 | */ |
||
136 | public function loadPlatform() { |
||
151 | |||
152 | |||
153 | /** |
||
154 | * not used yet. |
||
155 | */ |
||
156 | public function testPlatform() { |
||
158 | |||
159 | |||
160 | /** |
||
161 | * called before any index |
||
162 | * |
||
163 | * We create a general index. |
||
164 | * |
||
165 | * @param IFullTextSearchProvider $provider |
||
166 | * |
||
167 | * @throws ConfigurationException |
||
168 | */ |
||
169 | public function initializeIndex(IFullTextSearchProvider $provider) { |
||
174 | |||
175 | |||
176 | /** |
||
177 | * removeIndex(); |
||
178 | * |
||
179 | * Called when admin wants to remove an index specific to a $provider. |
||
180 | * $provider can be null, meaning a reset of the whole index. |
||
181 | * |
||
182 | * @param IFullTextSearchProvider|null $provider |
||
183 | * |
||
184 | * @throws ConfigurationException |
||
185 | */ |
||
186 | public function removeIndex($provider) { |
||
196 | |||
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | */ |
||
201 | public function indexDocuments(IFullTextSearchProvider $provider, $documents) { |
||
212 | |||
213 | |||
214 | /** |
||
215 | * {@inheritdoc} |
||
216 | */ |
||
217 | public function indexDocument(IFullTextSearchProvider $provider, IndexDocument $document) { |
||
232 | |||
233 | |||
234 | /** |
||
235 | * @param IFullTextSearchProvider $provider |
||
236 | * @param IndexDocument $document |
||
237 | * @param Exception $e |
||
238 | * |
||
239 | * @return Index |
||
240 | * @throws ConfigurationException |
||
241 | */ |
||
242 | private function indexDocumentError( |
||
243 | IFullTextSearchProvider $provider, IndexDocument $document, Exception $e |
||
244 | ) { |
||
245 | $message = [ |
||
246 | 'exception' => get_class($e), |
||
247 | 'message' => $e->getMessage() |
||
248 | ]; |
||
249 | |||
250 | $document->setContent(null); |
||
251 | $index = $document->getIndex(); |
||
252 | $index->unsetStatus(Index::INDEX_CONTENT); |
||
253 | $index->setMessage(json_encode($message)); |
||
254 | |||
255 | $result = $this->indexService->indexDocument($this, $this->client, $provider, $document); |
||
256 | $this->outputRunner(' result with no content: ' . json_encode($result)); |
||
257 | |||
258 | return $this->indexService->parseIndexResult($document->getIndex(), $result); |
||
259 | } |
||
260 | |||
261 | |||
262 | /** |
||
263 | * {@inheritdoc} |
||
264 | */ |
||
265 | public function searchDocuments(IFullTextSearchProvider $provider, DocumentAccess $access, $request |
||
275 | |||
276 | |||
277 | /** |
||
278 | * @param string $host |
||
279 | */ |
||
280 | private function connectToElastic($host) { |
||
299 | |||
300 | |||
301 | } |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.