@@ -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 | |
@@ -39,9 +39,9 @@ |
||
| 39 | 39 | class AlgoliaManager |
| 40 | 40 | { |
| 41 | 41 | /** |
| 42 | - * Size for the chunks used in reindexing methods. |
|
| 43 | - */ |
|
| 44 | - const CHUNK_SIZE = 500; |
|
| 42 | + * Size for the chunks used in reindexing methods. |
|
| 43 | + */ |
|
| 44 | + const CHUNK_SIZE = 500; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @var AlgoliaFactory |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); |
| 240 | 240 | $indices = $this->initIndices($searchableModels[0]); |
| 241 | - $objectIds = array_map(function ($algoliaRecord) { |
|
| 241 | + $objectIds = array_map(function($algoliaRecord) { |
|
| 242 | 242 | return $algoliaRecord['objectID']; |
| 243 | 243 | }, $algoliaRecords); |
| 244 | 244 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $records = $this->activeQueryChunker->chunk( |
| 268 | 268 | $activeRecord->find(), |
| 269 | 269 | self::CHUNK_SIZE, |
| 270 | - function ($activeRecordEntities) { |
|
| 270 | + function($activeRecordEntities) { |
|
| 271 | 271 | return $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities); |
| 272 | 272 | } |
| 273 | 273 | ); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $records = $this->activeQueryChunker->chunk( |
| 322 | 322 | $activeQuery, |
| 323 | 323 | self::CHUNK_SIZE, |
| 324 | - function ($activeRecordEntities) use (&$indices) { |
|
| 324 | + function($activeRecordEntities) use (&$indices) { |
|
| 325 | 325 | $records = $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities); |
| 326 | 326 | |
| 327 | 327 | // The converting ActiveRecords to Algolia ones already does the type checking |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | { |
| 390 | 390 | $reflectionClass = new \ReflectionClass($class); |
| 391 | 391 | |
| 392 | - if (! $reflectionClass->implementsInterface(SearchableInterface::class)) { |
|
| 392 | + if ( ! $reflectionClass->implementsInterface(SearchableInterface::class)) { |
|
| 393 | 393 | throw new \InvalidArgumentException("The class: {$reflectionClass->name} doesn't implement leinonen\\Yii2Algolia\\SearchableInterface"); |
| 394 | 394 | } |
| 395 | 395 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | { |
| 406 | 406 | $indexNames = $searchableModel->getIndices(); |
| 407 | 407 | |
| 408 | - $indices = array_map(function ($indexName) { |
|
| 408 | + $indices = array_map(function($indexName) { |
|
| 409 | 409 | if ($this->env !== null) { |
| 410 | - $indexName = $this->env . '_' . $indexName; |
|
| 410 | + $indexName = $this->env.'_'.$indexName; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | return $this->initIndex($indexName); |
@@ -432,8 +432,8 @@ discard block |
||
| 432 | 432 | // Use the first element of the array to define what kind of models we are indexing. |
| 433 | 433 | $arrayType = get_class($searchableModels[0]); |
| 434 | 434 | |
| 435 | - $algoliaRecords = array_map(function (SearchableInterface $searchableModel) use ($arrayType) { |
|
| 436 | - if (! $searchableModel instanceof $arrayType) { |
|
| 435 | + $algoliaRecords = array_map(function(SearchableInterface $searchableModel) use ($arrayType) { |
|
| 436 | + if ( ! $searchableModel instanceof $arrayType) { |
|
| 437 | 437 | throw new \InvalidArgumentException('The given array should not contain multiple different classes'); |
| 438 | 438 | } |
| 439 | 439 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | */ |
| 457 | 457 | private function reindexAtomically(Index $index, array $algoliaRecords) |
| 458 | 458 | { |
| 459 | - $temporaryIndexName = 'tmp_' . $index->indexName; |
|
| 459 | + $temporaryIndexName = 'tmp_'.$index->indexName; |
|
| 460 | 460 | |
| 461 | 461 | $temporaryIndex = $this->initIndex($temporaryIndexName); |
| 462 | 462 | $temporaryIndex->addObjects($algoliaRecords); |