1 | <?php |
||
39 | class AlgoliaManager |
||
40 | { |
||
41 | /** |
||
42 | * @var AlgoliaFactory |
||
43 | */ |
||
44 | protected $factory; |
||
45 | |||
46 | /** |
||
47 | * @var AlgoliaConfig |
||
48 | */ |
||
49 | protected $config; |
||
50 | |||
51 | /** |
||
52 | * @var Client |
||
53 | */ |
||
54 | protected $client; |
||
55 | |||
56 | /** |
||
57 | * @var ActiveRecordFactory |
||
58 | */ |
||
59 | protected $activeRecordFactory; |
||
60 | |||
61 | /** |
||
62 | * @var null|string |
||
63 | */ |
||
64 | protected $env; |
||
65 | |||
66 | /** |
||
67 | * @var ActiveQueryChunker |
||
68 | */ |
||
69 | private $activeQueryChunker; |
||
70 | |||
71 | /** |
||
72 | * Initiates a new AlgoliaManager. |
||
73 | * |
||
74 | * @param Client $client |
||
75 | * @param ActiveRecordFactory $activeRecordFactory |
||
76 | * @param ActiveQueryChunker $activeQueryChunker |
||
77 | */ |
||
78 | 39 | public function __construct( |
|
87 | |||
88 | /** |
||
89 | * Returns the Algolia Client. |
||
90 | * |
||
91 | * @return Client |
||
92 | */ |
||
93 | 17 | public function getClient() |
|
97 | |||
98 | /** |
||
99 | * Sets the environment for the manager. |
||
100 | * |
||
101 | * @param string $env |
||
102 | */ |
||
103 | 39 | public function setEnv($env) |
|
107 | |||
108 | /** |
||
109 | * Returns the environment for the manager. |
||
110 | * |
||
111 | * @return null|string |
||
112 | */ |
||
113 | 1 | public function getEnv() |
|
117 | |||
118 | /** |
||
119 | * Indexes a searchable model to all indices. |
||
120 | * |
||
121 | * @param SearchableInterface $searchableModel |
||
122 | * |
||
123 | * @return array |
||
124 | */ |
||
125 | 5 | public function pushToIndices(SearchableInterface $searchableModel) |
|
137 | |||
138 | /** |
||
139 | * Indexes multiple searchable models in a batch. The given searchable models must be of the same class. |
||
140 | * |
||
141 | * @param SearchableInterface[] $searchableModels |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | 3 | public function pushMultipleToIndices(array $searchableModels) |
|
159 | |||
160 | /** |
||
161 | * Updates the models data in all indices. |
||
162 | * |
||
163 | * @param SearchableInterface $searchableModel |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | 3 | public function updateInIndices(SearchableInterface $searchableModel) |
|
180 | |||
181 | /** |
||
182 | * Updates multiple models data in all indices. The given searchable models must be of the same class. |
||
183 | * |
||
184 | * @param SearchableInterface[] $searchableModels |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | 2 | public function updateMultipleInIndices(array $searchableModels) |
|
202 | |||
203 | /** |
||
204 | * Removes a searchable model from indices. |
||
205 | * |
||
206 | * @param SearchableInterface $searchableModel |
||
207 | * |
||
208 | * @return array |
||
209 | * @throws \Exception |
||
210 | */ |
||
211 | 2 | public function removeFromIndices(SearchableInterface $searchableModel) |
|
223 | |||
224 | /** |
||
225 | * Re-indexes the indices safely for the given ActiveRecord Class. |
||
226 | * |
||
227 | * @param string $className The name of the ActiveRecord to be indexed |
||
228 | * |
||
229 | * @return array |
||
230 | */ |
||
231 | 3 | public function reindex($className) |
|
265 | |||
266 | /** |
||
267 | * Clears the indices for the given Class that implements SearchableInterface. |
||
268 | * |
||
269 | * @param string $className The name of the Class which indices are to be cleared. |
||
270 | * |
||
271 | * @return array |
||
272 | */ |
||
273 | 2 | public function clearIndices($className) |
|
288 | |||
289 | /** |
||
290 | * Dynamically pass methods to the Algolia Client. |
||
291 | * |
||
292 | * @param string $method |
||
293 | * @param array $parameters |
||
294 | * |
||
295 | * @return mixed |
||
296 | */ |
||
297 | 14 | public function __call($method, $parameters) |
|
301 | |||
302 | /** |
||
303 | * Checks if the given class implements SearchableInterface. |
||
304 | * |
||
305 | * @param string $class Either name or instance of the class to be checked. |
||
306 | */ |
||
307 | 5 | private function checkImplementsSearchableInterface($class) |
|
315 | |||
316 | /** |
||
317 | * Initializes indices for the given SearchableModel. |
||
318 | * |
||
319 | * @param SearchableInterface $searchableModel |
||
320 | * |
||
321 | * @return Index[] |
||
322 | */ |
||
323 | 13 | private function initIndices(SearchableInterface $searchableModel) |
|
337 | |||
338 | /** |
||
339 | * Maps an array of searchable models into an Algolia friendly array. |
||
340 | * |
||
341 | * @param SearchableInterface[] $searchableModels |
||
342 | * |
||
343 | * @return array |
||
344 | */ |
||
345 | 7 | private function getAlgoliaRecordsFromSearchableModelArray(array $searchableModels) |
|
363 | } |
||
364 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: