Passed
Push — v3 ( dc9fae...2f2fc6 )
by Andrew
18:54 queued 11:52
created
src/Retour.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
     /**
120 120
      * @inheritdoc
121 121
      */
122
-    public function __construct($id, $parent = null, array $config = [])
122
+    public function __construct($id, $parent = null, array $config = [ ])
123 123
     {
124
-        $config['components'] = [
124
+        $config[ 'components' ] = [
125 125
             'redirects' => Redirects::class,
126 126
             'statistics' => Statistics::class,
127 127
             // Register the manifest service
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     /**
158 158
      * @var array The URIs for the element before it was saved
159 159
      */
160
-    public $oldElementUris = [];
160
+    public $oldElementUris = [ ];
161 161
 
162 162
     // Public Methods
163 163
     // =========================================================================
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             Craft::t(
191 191
                 'retour',
192 192
                 '{name} plugin loaded',
193
-                ['name' => $this->name]
193
+                [ 'name' => $this->name ]
194 194
             ),
195 195
             __METHOD__
196 196
         );
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function getCpNavItem()
212 212
     {
213
-        $subNavs = [];
213
+        $subNavs = [ ];
214 214
         $navItem = parent::getCpNavItem();
215 215
         $currentUser = Craft::$app->getUser()->getIdentity();
216 216
         // Only show sub-navs the user has permission to view
217 217
         if ($currentUser->can('retour:dashboard')) {
218
-            $subNavs['dashboard'] = [
218
+            $subNavs[ 'dashboard' ] = [
219 219
                 'label' => 'Dashboard',
220 220
                 'url' => 'retour/dashboard',
221 221
             ];
222 222
         }
223 223
         if ($currentUser->can('retour:redirects')) {
224
-            $subNavs['redirects'] = [
224
+            $subNavs[ 'redirects' ] = [
225 225
                 'label' => 'Redirects',
226 226
                 'url' => 'retour/redirects',
227 227
             ];
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             $editableSettings = false;
233 233
         }
234 234
         if ($currentUser->can('retour:settings') && $editableSettings) {
235
-            $subNavs['settings'] = [
235
+            $subNavs[ 'settings' ] = [
236 236
                 'label' => 'Settings',
237 237
                 'url' => 'retour/settings',
238 238
             ];
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         Event::on(
292 292
             ClearCaches::class,
293 293
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
294
-            function (RegisterCacheOptionsEvent $event) {
294
+            function(RegisterCacheOptionsEvent $event) {
295 295
                 Craft::debug(
296 296
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
297 297
                     __METHOD__
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         Event::on(
308 308
             Plugins::class,
309 309
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
310
-            function (PluginEvent $event) {
310
+            function(PluginEvent $event) {
311 311
                 if ($event->plugin === $this) {
312 312
                     // Invalidate our caches after we've been installed
313 313
                     $this->clearAllCaches();
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         Event::on(
335 335
             CraftVariable::class,
336 336
             CraftVariable::EVENT_INIT,
337
-            function (Event $event) {
337
+            function(Event $event) {
338 338
                 /** @var CraftVariable $variable */
339 339
                 $variable = $event->sender;
340 340
                 $variable->set('retour', [
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
         Event::on(
348 348
             Elements::class,
349 349
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
350
-            function (ElementEvent $event) {
350
+            function(ElementEvent $event) {
351 351
                 Craft::debug(
352 352
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
353 353
                     __METHOD__
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
371 371
                             // Stash the old URLs by element id, and do so only once,
372 372
                             // in case we are called more than once per request
373
-                            if (empty($this->oldElementUris[$element->id])) {
374
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
373
+                            if (empty($this->oldElementUris[ $element->id ])) {
374
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
375 375
                             }
376 376
                         }
377 377
                     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         Event::on(
383 383
             Elements::class,
384 384
             Elements::EVENT_AFTER_SAVE_ELEMENT,
385
-            function (ElementEvent $event) {
385
+            function(ElementEvent $event) {
386 386
                 Craft::debug(
387 387
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
388 388
                     __METHOD__
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
         Event::on(
405 405
             Plugins::class,
406 406
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
407
-            function () {
407
+            function() {
408 408
                 // Install these only after all other plugins have loaded
409 409
                 $request = Craft::$app->getRequest();
410 410
                 // Only respond to non-console site requests
@@ -422,26 +422,26 @@  discard block
 block discarded – undo
422 422
             Event::on(
423 423
                 Gql::class,
424 424
                 Gql::EVENT_REGISTER_GQL_TYPES,
425
-                function (RegisterGqlTypesEvent $event) {
425
+                function(RegisterGqlTypesEvent $event) {
426 426
                     Craft::debug(
427 427
                         'Gql::EVENT_REGISTER_GQL_TYPES',
428 428
                         __METHOD__
429 429
                     );
430
-                    $event->types[] = RetourInterface::class;
430
+                    $event->types[ ] = RetourInterface::class;
431 431
                 }
432 432
             );
433 433
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
434 434
             Event::on(
435 435
                 Gql::class,
436 436
                 Gql::EVENT_REGISTER_GQL_QUERIES,
437
-                function (RegisterGqlQueriesEvent $event) {
437
+                function(RegisterGqlQueriesEvent $event) {
438 438
                     Craft::debug(
439 439
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
440 440
                         __METHOD__
441 441
                     );
442 442
                     $queries = RetourQuery::getQueries();
443 443
                     foreach ($queries as $key => $value) {
444
-                        $event->queries[$key] = $value;
444
+                        $event->queries[ $key ] = $value;
445 445
                     }
446 446
                 }
447 447
             );
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
             Event::on(
452 452
                 Schema::class,
453 453
                 AlterSchemaFields::EVENT,
454
-                [GetCraftQLSchema::class, 'handle']
454
+                [ GetCraftQLSchema::class, 'handle' ]
455 455
             );
456 456
         }
457 457
     }
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         Event::on(
466 466
             UrlManager::class,
467 467
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
468
-            function (RegisterUrlRulesEvent $event) {
468
+            function(RegisterUrlRulesEvent $event) {
469 469
                 Craft::debug(
470 470
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
471 471
                     __METHOD__
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
         Event::on(
489 489
             Dashboard::class,
490 490
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
491
-            function (RegisterComponentTypesEvent $event) {
492
-                $event->types[] = RetourWidget::class;
491
+            function(RegisterComponentTypesEvent $event) {
492
+                $event->types[ ] = RetourWidget::class;
493 493
             }
494 494
         );
495 495
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
496 496
         Event::on(
497 497
             UrlManager::class,
498 498
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
499
-            function (RegisterUrlRulesEvent $event) {
499
+            function(RegisterUrlRulesEvent $event) {
500 500
                 Craft::debug(
501 501
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
502 502
                     __METHOD__
@@ -512,13 +512,13 @@  discard block
 block discarded – undo
512 512
         Event::on(
513 513
             UserPermissions::class,
514 514
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
515
-            function (RegisterUserPermissionsEvent $event) {
515
+            function(RegisterUserPermissionsEvent $event) {
516 516
                 Craft::debug(
517 517
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
518 518
                     __METHOD__
519 519
                 );
520 520
                 // Register our custom permissions
521
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
521
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
522 522
             }
523 523
         );
524 524
     }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
         Event::on(
535 535
             ErrorHandler::class,
536 536
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
537
-            function (ExceptionEvent $event) {
537
+            function(ExceptionEvent $event) {
538 538
                 Craft::debug(
539 539
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
540 540
                     __METHOD__
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
     protected function handleElementUriChange(Element $element)
578 578
     {
579 579
         $uris = $this->getAllElementUris($element);
580
-        if (!empty($this->oldElementUris[$element->id])) {
581
-            $oldElementUris = $this->oldElementUris[$element->id];
580
+        if (!empty($this->oldElementUris[ $element->id ])) {
581
+            $oldElementUris = $this->oldElementUris[ $element->id ];
582 582
             foreach ($uris as $siteId => $newUri) {
583
-                if (!empty($oldElementUris[$siteId])) {
584
-                    $oldUri = $oldElementUris[$siteId];
583
+                if (!empty($oldElementUris[ $siteId ])) {
584
+                    $oldUri = $oldElementUris[ $siteId ];
585 585
                     Craft::debug(
586 586
                         Craft::t(
587 587
                             'retour',
588 588
                             'Comparing old: {oldUri} to new: {newUri}',
589
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
589
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
590 590
                         ),
591 591
                         __METHOD__
592 592
                     );
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
                         if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') {
607 607
                             try {
608 608
                                 if ($redirectSiteId !== null) {
609
-                                    $redirectSiteId = (int)$redirectSiteId;
609
+                                    $redirectSiteId = (int) $redirectSiteId;
610 610
                                 }
611 611
                                 $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId);
612 612
                                 $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId);
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
      */
640 640
     protected function getAllElementUris(Element $element): array
641 641
     {
642
-        $uris = [];
642
+        $uris = [ ];
643 643
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
644 644
             $sites = Craft::$app->getSites()->getAllSites();
645 645
             foreach ($sites as $site) {
646 646
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
647 647
                 if ($uri !== null) {
648
-                    $uris[$site->id] = $uri;
648
+                    $uris[ $site->id ] = $uri;
649 649
                 }
650 650
             }
651 651
         }
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
             Craft::t(
655 655
                 'retour',
656 656
                 'Getting Element URIs: {uris}',
657
-                ['uris' => print_r($uris, true)]
657
+                [ 'uris' => print_r($uris, true) ]
658 658
             ),
659 659
             __METHOD__
660 660
         );
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
             [
710 710
                 'key' => 'retour-redirect-caches',
711 711
                 'label' => Craft::t('retour', 'Retour redirect caches'),
712
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
712
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
713 713
             ],
714 714
         ];
715 715
     }
Please login to merge, or discard this patch.