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) { |
||
226 | |||
227 | |||
228 | /** |
||
229 | * @param IndexDocument $document |
||
230 | * |
||
231 | * @return bool |
||
232 | */ |
||
233 | public function isDocumentUpToDate($document) { |
||
236 | |||
237 | |||
238 | /** |
||
239 | * @param Index $index |
||
240 | * |
||
241 | * @return BookmarksDocument|null |
||
242 | */ |
||
243 | public function updateDocument(Index $index) { |
||
246 | |||
247 | |||
248 | /** |
||
249 | * @param IFullTextSearchPlatform $platform |
||
250 | */ |
||
251 | public function onInitializingIndex(IFullTextSearchPlatform $platform) { |
||
254 | |||
255 | |||
256 | /** |
||
257 | * @param IFullTextSearchPlatform $platform |
||
258 | */ |
||
259 | public function onResettingIndex(IFullTextSearchPlatform $platform) { |
||
262 | |||
263 | |||
264 | /** |
||
265 | * not used yet |
||
266 | */ |
||
267 | public function unloadProvider() { |
||
269 | |||
270 | |||
271 | /** |
||
272 | * before a search, improve the request |
||
273 | * |
||
274 | * @param SearchRequest $request |
||
275 | */ |
||
276 | public function improveSearchRequest(SearchRequest $request) { |
||
279 | |||
280 | |||
281 | /** |
||
282 | * after a search, improve results |
||
283 | * |
||
284 | * @param SearchResult $searchResult |
||
285 | */ |
||
286 | public function improveSearchResult(SearchResult $searchResult) { |
||
292 | |||
293 | |||
294 | /** |
||
295 | * @param IndexDocument $document |
||
296 | * @param Exception $e |
||
297 | */ |
||
298 | private function manageErrorException(IndexDocument $document, Exception $e) { |
||
305 | |||
306 | |||
307 | /** |
||
308 | * @param Index $index |
||
309 | * @param string $message |
||
310 | * @param string $exception |
||
311 | * @param int $sev |
||
312 | */ |
||
313 | private function updateNewIndexError($index, $message, $exception, $sev) { |
||
320 | |||
321 | |||
322 | } |
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.