1 | <?php |
||
49 | class BookmarksProvider implements IFullTextSearchProvider { |
||
50 | |||
51 | |||
52 | const BOOKMARKS_PROVIDER_ID = 'bookmarks'; |
||
53 | |||
54 | /** @var ConfigService */ |
||
55 | private $configService; |
||
56 | |||
57 | /** @var BookmarksService */ |
||
58 | private $bookmarksService; |
||
59 | |||
60 | /** @var TagsService */ |
||
61 | private $tagsService; |
||
62 | |||
63 | /** @var SearchService */ |
||
64 | private $searchService; |
||
65 | |||
66 | /** @var ElasticSearchService */ |
||
67 | private $elasticSearchService; |
||
68 | |||
69 | /** @var MiscService */ |
||
70 | private $miscService; |
||
71 | |||
72 | |||
73 | /** @var Runner */ |
||
74 | private $runner; |
||
75 | |||
76 | /** @var IndexOptions */ |
||
77 | private $indexOptions; |
||
78 | |||
79 | |||
80 | /** |
||
81 | * return unique id of the provider |
||
82 | */ |
||
83 | public function getId() { |
||
84 | return self::BOOKMARKS_PROVIDER_ID; |
||
85 | } |
||
86 | |||
87 | |||
88 | /** |
||
89 | * return name of the provider |
||
90 | */ |
||
91 | public function getName() { |
||
92 | return 'Bookmarks'; |
||
93 | } |
||
94 | |||
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getVersion() { |
||
100 | return $this->configService->getAppValue('installed_version'); |
||
101 | } |
||
102 | |||
103 | |||
104 | /** |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getAppId() { |
||
108 | return Application::APP_NAME; |
||
109 | } |
||
110 | |||
111 | |||
112 | /** |
||
113 | * @return array |
||
114 | */ |
||
115 | public function getConfiguration() { |
||
116 | return $this->configService->getConfig(); |
||
117 | } |
||
118 | |||
119 | |||
120 | /** |
||
121 | * @param Runner $runner |
||
122 | */ |
||
123 | public function setRunner(Runner $runner) { |
||
124 | $this->runner = $runner; |
||
125 | } |
||
126 | |||
127 | |||
128 | /** |
||
129 | * @param IndexOptions $options |
||
130 | */ |
||
131 | public function setIndexOptions($options) { |
||
132 | $this->indexOptions = $options; |
||
133 | } |
||
134 | |||
135 | |||
136 | /** |
||
137 | * @return array |
||
|
|||
138 | */ |
||
139 | public function getOptionsTemplate() { |
||
140 | return [ |
||
141 | 'navigation' => [ |
||
142 | 'icon' => 'icon-fts-bookmarks', |
||
143 | // 'options' => [ |
||
144 | // [ |
||
145 | // 'name' => 'bookmarks_tags', |
||
146 | // 'title' => 'Filter tags', |
||
147 | // 'type' => 'tags', |
||
148 | // 'list' => $this->tagsService->getAllForUser() |
||
149 | // ] |
||
150 | // ] |
||
151 | ] |
||
152 | ]; |
||
153 | } |
||
154 | |||
155 | |||
156 | /** |
||
157 | * called when loading all providers. |
||
158 | * |
||
159 | * Loading some containers. |
||
160 | * |
||
161 | * @throws QueryException |
||
162 | */ |
||
163 | public function loadProvider() { |
||
179 | |||
180 | |||
181 | /** |
||
182 | * returns all indexable document for a user. |
||
183 | * There is no need to fill the document with content at this point. |
||
184 | * |
||
185 | * $platform is provided if the mapping needs to be changed. |
||
186 | * |
||
187 | * @param string $userId |
||
188 | * |
||
189 | * @return BookmarksDocument[] |
||
190 | */ |
||
191 | public function generateIndexableDocuments($userId) { |
||
196 | |||
197 | |||
198 | /** |
||
199 | * generate documents prior to the indexing. |
||
200 | * throw NoResultException if no more result |
||
201 | * |
||
202 | * @param IndexDocument[] $chunk |
||
203 | * |
||
204 | * @return IndexDocument[] |
||
205 | */ |
||
206 | public function fillIndexDocuments($chunk) { |
||
209 | |||
210 | // |
||
211 | // $index = []; |
||
212 | // /** @var BookmarksDocument[] $chunk */ |
||
213 | // foreach ($chunk as $document) { |
||
214 | // if (!($document instanceof BookmarksDocument)) { |
||
215 | // continue; |
||
216 | // } |
||
217 | // |
||
218 | // try { |
||
219 | // $this->bookmarksService->updateDocumentFromBookmarksDocument($document); |
||
220 | // } catch (Exception $e) { |
||
221 | // $this->manageErrorException($document, $e); |
||
222 | // } |
||
223 | // |
||
224 | // $index[] = $document; |
||
225 | // } |
||
226 | // |
||
227 | // return $index; |
||
228 | // } |
||
229 | |||
230 | /** |
||
231 | * @param IndexDocument $document |
||
232 | */ |
||
233 | public function fillIndexDocument(IndexDocument $document) { |
||
244 | |||
245 | |||
246 | /** |
||
247 | * @param IndexDocument $document |
||
248 | * |
||
249 | * @return bool |
||
250 | */ |
||
251 | public function isDocumentUpToDate($document) { |
||
254 | |||
255 | |||
256 | /** |
||
257 | * @param Index $index |
||
258 | * |
||
259 | * @return BookmarksDocument|null |
||
260 | */ |
||
261 | public function updateDocument(Index $index) { |
||
264 | |||
265 | |||
266 | /** |
||
267 | * @param IFullTextSearchPlatform $platform |
||
268 | */ |
||
269 | public function onInitializingIndex(IFullTextSearchPlatform $platform) { |
||
272 | |||
273 | |||
274 | /** |
||
275 | * @param IFullTextSearchPlatform $platform |
||
276 | */ |
||
277 | public function onResettingIndex(IFullTextSearchPlatform $platform) { |
||
280 | |||
281 | |||
282 | /** |
||
283 | * not used yet |
||
284 | */ |
||
285 | public function unloadProvider() { |
||
287 | |||
288 | |||
289 | /** |
||
290 | * before a search, improve the request |
||
291 | * |
||
292 | * @param SearchRequest $request |
||
293 | */ |
||
294 | public function improveSearchRequest(SearchRequest $request) { |
||
297 | |||
298 | |||
299 | /** |
||
300 | * after a search, improve results |
||
301 | * |
||
302 | * @param SearchResult $searchResult |
||
303 | */ |
||
304 | public function improveSearchResult(SearchResult $searchResult) { |
||
310 | |||
311 | |||
312 | /** |
||
313 | * @param IndexDocument $document |
||
314 | * @param Exception $e |
||
315 | */ |
||
316 | private function manageErrorException(IndexDocument $document, Exception $e) { |
||
323 | |||
324 | |||
325 | /** |
||
326 | * @param Index $index |
||
327 | * @param string $message |
||
328 | * @param string $exception |
||
329 | * @param int $sev |
||
330 | */ |
||
331 | private function updateNewIndexError($index, $message, $exception, $sev) { |
||
338 | |||
339 | |||
340 | /** |
||
341 | * @param string $info |
||
342 | * @param string $value |
||
343 | */ |
||
344 | private function updateRunnerInfo($info, $value) { |
||
351 | |||
352 | |||
353 | } |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.