1 | <?php |
||
55 | class TestProvider implements IFullTextSearchProvider { |
||
56 | |||
57 | |||
58 | const TEST_PROVIDER_ID = 'test_provider'; |
||
59 | |||
60 | /** @var ConfigService */ |
||
61 | private $configService; |
||
62 | |||
63 | /** @var TestService */ |
||
64 | private $testService; |
||
65 | |||
66 | /** @var MiscService */ |
||
67 | private $miscService; |
||
68 | |||
69 | /** @var Runner */ |
||
70 | private $runner; |
||
71 | |||
72 | /** @var IndexOptions */ |
||
73 | private $indexOptions; |
||
74 | |||
75 | |||
76 | /** |
||
77 | * TestProvider constructor. |
||
78 | * |
||
79 | * @param ConfigService $configService |
||
80 | * @param TestService $testService |
||
81 | * @param MiscService $miscService |
||
82 | */ |
||
83 | public function __construct( |
||
84 | ConfigService $configService, TestService $testService, MiscService $miscService |
||
85 | ) { |
||
86 | $this->configService = $configService; |
||
87 | $this->testService = $testService; |
||
88 | $this->miscService = $miscService; |
||
89 | } |
||
90 | |||
91 | |||
92 | /** |
||
93 | * return unique id of the provider |
||
94 | */ |
||
95 | public function getId(): string { |
||
96 | return self::TEST_PROVIDER_ID; |
||
97 | } |
||
98 | |||
99 | |||
100 | /** |
||
101 | * return name of the provider |
||
102 | */ |
||
103 | public function getName(): string { |
||
104 | return 'Test Provider'; |
||
105 | } |
||
106 | |||
107 | |||
108 | /** |
||
109 | * @return array |
||
110 | */ |
||
111 | public function getConfiguration(): array { |
||
112 | return $this->configService->getConfig(); |
||
113 | } |
||
114 | |||
115 | |||
116 | public function setRunner(IRunner $runner) { |
||
117 | $this->runner = $runner; |
||
|
|||
118 | } |
||
119 | |||
120 | |||
121 | /** |
||
122 | * @param IIndexOptions $options |
||
123 | */ |
||
124 | public function setIndexOptions(IIndexOptions $options) { |
||
125 | $this->indexOptions = $options; |
||
126 | } |
||
127 | |||
128 | |||
129 | /** |
||
130 | * @return SearchTemplate |
||
131 | */ |
||
132 | public function getSearchTemplate(): SearchTemplate { |
||
133 | return new SearchTemplate(); |
||
134 | } |
||
135 | |||
136 | |||
137 | /** |
||
138 | * called when loading all providers. |
||
139 | * |
||
140 | * Loading some containers. |
||
141 | */ |
||
142 | public function loadProvider() { |
||
143 | } |
||
144 | |||
145 | |||
146 | public function generateChunks(string $userId): array { |
||
147 | return []; |
||
148 | } |
||
149 | |||
150 | |||
151 | /** |
||
152 | * returns all indexable document for a user. |
||
153 | * There is no need to fill the document with content at this point. |
||
154 | * |
||
155 | * $platform is provided if the mapping needs to be changed. |
||
156 | * |
||
157 | * @param string $userId |
||
158 | * @param string $chunk |
||
159 | * |
||
160 | * @return IndexDocument[] |
||
161 | */ |
||
162 | public function generateIndexableDocuments(string $userId, string $chunk): array { |
||
163 | $result = []; |
||
164 | |||
165 | $result[] = $this->testService->generateIndexDocumentContentLicense($this->indexOptions); |
||
166 | $result[] = $this->testService->generateIndexDocumentSimple($this->indexOptions); |
||
167 | |||
168 | return $result; |
||
169 | } |
||
170 | |||
171 | |||
172 | /** |
||
173 | * generate documents prior to the indexing. |
||
174 | * |
||
175 | * @param IndexDocument $document |
||
176 | */ |
||
177 | public function fillIndexDocument(IndexDocument $document) { |
||
179 | |||
180 | |||
181 | /** |
||
182 | * @param IndexDocument $document |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | public function isDocumentUpToDate(IndexDocument $document): bool { |
||
189 | |||
190 | |||
191 | /** |
||
192 | * @param IIndex $index |
||
193 | * |
||
194 | * @return IndexDocument |
||
195 | */ |
||
196 | public function updateDocument(IIndex $index): IndexDocument { |
||
199 | |||
200 | |||
201 | /** |
||
202 | * @param IFullTextSearchPlatform $platform |
||
203 | */ |
||
204 | public function onInitializingIndex(IFullTextSearchPlatform $platform) { |
||
206 | |||
207 | |||
208 | /** |
||
209 | * @param IFullTextSearchPlatform $platform |
||
210 | */ |
||
211 | public function onResettingIndex(IFullTextSearchPlatform $platform) { |
||
213 | |||
214 | |||
215 | /** |
||
216 | * not used yet |
||
217 | */ |
||
218 | public function unloadProvider() { |
||
220 | |||
221 | |||
222 | /** |
||
223 | * before a search, improve the request |
||
224 | * |
||
225 | * @param ISearchRequest $request |
||
226 | */ |
||
227 | public function improveSearchRequest(ISearchRequest $request) { |
||
229 | |||
230 | |||
231 | /** |
||
232 | * after a search, improve results |
||
233 | * |
||
234 | * @param ISearchResult $searchResult |
||
235 | */ |
||
236 | public function improveSearchResult(ISearchResult $searchResult) { |
||
238 | |||
239 | } |
||
240 | |||
241 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.