@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | public function bootstrap($app) |
44 | 44 | { |
45 | - Yii::$container->set(AlgoliaManager::class, function () { |
|
45 | + Yii::$container->set(AlgoliaManager::class, function() { |
|
46 | 46 | return $this->createManager(); |
47 | 47 | }); |
48 | 48 | } |
@@ -37,21 +37,21 @@ |
||
37 | 37 | public function events() |
38 | 38 | { |
39 | 39 | return [ |
40 | - ActiveRecord::EVENT_AFTER_INSERT => function (Event $event) { |
|
40 | + ActiveRecord::EVENT_AFTER_INSERT => function(Event $event) { |
|
41 | 41 | if ($this->afterInsert) { |
42 | 42 | /** @var $manager AlgoliaManager */ |
43 | 43 | $manager = Yii::$container->get(AlgoliaManager::class); |
44 | 44 | $manager->pushToIndices($event->sender); |
45 | 45 | } |
46 | 46 | }, |
47 | - ActiveRecord::EVENT_AFTER_DELETE => function (Event $event) { |
|
47 | + ActiveRecord::EVENT_AFTER_DELETE => function(Event $event) { |
|
48 | 48 | if ($this->afterDelete) { |
49 | 49 | /** @var $manager AlgoliaManager */ |
50 | 50 | $manager = Yii::$container->get(AlgoliaManager::class); |
51 | 51 | $manager->removeFromIndices($event->sender); |
52 | 52 | } |
53 | 53 | }, |
54 | - ActiveRecord::EVENT_AFTER_UPDATE => function (Event $event) { |
|
54 | + ActiveRecord::EVENT_AFTER_UPDATE => function(Event $event) { |
|
55 | 55 | if ($this->afterUpdate) { |
56 | 56 | /** @var $manager AlgoliaManager */ |
57 | 57 | $manager = Yii::$container->get(AlgoliaManager::class); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function make($className) |
17 | 17 | { |
18 | - if (! (new \ReflectionClass($className))->implementsInterface(ActiveRecordInterface::class)) { |
|
18 | + if ( ! (new \ReflectionClass($className))->implementsInterface(ActiveRecordInterface::class)) { |
|
19 | 19 | throw new \InvalidArgumentException("Cannot initiate a class ({$className}) which doesn't implement \\yii\\db\\ActiveRecordInterface"); |
20 | 20 | } |
21 | 21 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | */ |
34 | 34 | public function makeSearchableObject($className) |
35 | 35 | { |
36 | - if (! (new \ReflectionClass($className))->implementsInterface(SearchableInterface::class)) { |
|
36 | + if ( ! (new \ReflectionClass($className))->implementsInterface(SearchableInterface::class)) { |
|
37 | 37 | throw new \InvalidArgumentException("Cannot initiate a class ({$className}) which doesn't implement leinonen\\Yii2Algolia\\SearchableInterface"); |
38 | 38 | } |
39 | 39 |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $records = $this->activeQueryChunker->chunk( |
237 | 237 | $activeRecord->find(), |
238 | 238 | 500, |
239 | - function ($activeRecordEntities) { |
|
239 | + function($activeRecordEntities) { |
|
240 | 240 | return $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities); |
241 | 241 | } |
242 | 242 | ); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $response = []; |
245 | 245 | |
246 | 246 | foreach ($indices as $index) { |
247 | - $temporaryIndexName = 'tmp_' . $index->indexName; |
|
247 | + $temporaryIndexName = 'tmp_'.$index->indexName; |
|
248 | 248 | |
249 | 249 | /** @var Index $temporaryIndex */ |
250 | 250 | $temporaryIndex = $this->initIndex($temporaryIndexName); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | { |
308 | 308 | $reflectionClass = new \ReflectionClass($class); |
309 | 309 | |
310 | - if (! $reflectionClass->implementsInterface(SearchableInterface::class)) { |
|
310 | + if ( ! $reflectionClass->implementsInterface(SearchableInterface::class)) { |
|
311 | 311 | throw new \InvalidArgumentException("The class: {$reflectionClass->name} doesn't implement leinonen\\Yii2Algolia\\SearchableInterface"); |
312 | 312 | } |
313 | 313 | } |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | { |
324 | 324 | $indexNames = $searchableModel->getIndices(); |
325 | 325 | |
326 | - $indices = array_map(function ($indexName) { |
|
326 | + $indices = array_map(function($indexName) { |
|
327 | 327 | if ($this->env !== null) { |
328 | - $indexName = $this->env . '_' . $indexName; |
|
328 | + $indexName = $this->env.'_'.$indexName; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $this->initIndex($indexName); |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | // Use the first element of the array to define what kind of models we are indexing. |
347 | 347 | $arrayType = get_class($searchableModels[0]); |
348 | 348 | |
349 | - $algoliaRecords = array_map(function (SearchableInterface $searchableModel) use ($arrayType) { |
|
350 | - if (! $searchableModel instanceof $arrayType) { |
|
349 | + $algoliaRecords = array_map(function(SearchableInterface $searchableModel) use ($arrayType) { |
|
350 | + if ( ! $searchableModel instanceof $arrayType) { |
|
351 | 351 | throw new \InvalidArgumentException('The given array should not contain multiple different classes'); |
352 | 352 | } |
353 | 353 |