Passed
Pull Request — v3 (#175)
by M. Mikkel
06:51
created
src/Retour.php 1 patch
Spacing   +39 added lines, -39 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
             ];
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         }
244 244
         // A single sub nav item is redundant
245 245
         if (count($subNavs) === 1) {
246
-            $subNavs = [];
246
+            $subNavs = [ ];
247 247
         }
248 248
         $navItem = array_merge($navItem, [
249 249
             'subnav' => $subNavs,
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         Event::on(
300 300
             ClearCaches::class,
301 301
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
302
-            function (RegisterCacheOptionsEvent $event) {
302
+            function(RegisterCacheOptionsEvent $event) {
303 303
                 Craft::debug(
304 304
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
305 305
                     __METHOD__
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         Event::on(
316 316
             Plugins::class,
317 317
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
318
-            function (PluginEvent $event) {
318
+            function(PluginEvent $event) {
319 319
                 if ($event->plugin === $this) {
320 320
                     // Invalidate our caches after we've been installed
321 321
                     $this->clearAllCaches();
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         Event::on(
343 343
             CraftVariable::class,
344 344
             CraftVariable::EVENT_INIT,
345
-            function (Event $event) {
345
+            function(Event $event) {
346 346
                 /** @var CraftVariable $variable */
347 347
                 $variable = $event->sender;
348 348
                 $variable->set('retour', [
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         Event::on(
356 356
             Elements::class,
357 357
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
358
-            function (ElementEvent $event) {
358
+            function(ElementEvent $event) {
359 359
                 Craft::debug(
360 360
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
361 361
                     __METHOD__
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
379 379
                             // Stash the old URLs by element id, and do so only once,
380 380
                             // in case we are called more than once per request
381
-                            if (empty($this->oldElementUris[$element->id])) {
382
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
381
+                            if (empty($this->oldElementUris[ $element->id ])) {
382
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
383 383
                             }
384 384
                         }
385 385
                     }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         Event::on(
391 391
             Elements::class,
392 392
             Elements::EVENT_AFTER_SAVE_ELEMENT,
393
-            function (ElementEvent $event) {
393
+            function(ElementEvent $event) {
394 394
                 Craft::debug(
395 395
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
396 396
                     __METHOD__
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         Event::on(
413 413
             Plugins::class,
414 414
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
415
-            function () {
415
+            function() {
416 416
                 // Install these only after all other plugins have loaded
417 417
                 $request = Craft::$app->getRequest();
418 418
                 // Only respond to non-console site requests
@@ -430,26 +430,26 @@  discard block
 block discarded – undo
430 430
             Event::on(
431 431
                 Gql::class,
432 432
                 Gql::EVENT_REGISTER_GQL_TYPES,
433
-                function (RegisterGqlTypesEvent $event) {
433
+                function(RegisterGqlTypesEvent $event) {
434 434
                     Craft::debug(
435 435
                         'Gql::EVENT_REGISTER_GQL_TYPES',
436 436
                         __METHOD__
437 437
                     );
438
-                    $event->types[] = RetourInterface::class;
438
+                    $event->types[ ] = RetourInterface::class;
439 439
                 }
440 440
             );
441 441
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
442 442
             Event::on(
443 443
                 Gql::class,
444 444
                 Gql::EVENT_REGISTER_GQL_QUERIES,
445
-                function (RegisterGqlQueriesEvent $event) {
445
+                function(RegisterGqlQueriesEvent $event) {
446 446
                     Craft::debug(
447 447
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
448 448
                         __METHOD__
449 449
                     );
450 450
                     $queries = RetourQuery::getQueries();
451 451
                     foreach ($queries as $key => $value) {
452
-                        $event->queries[$key] = $value;
452
+                        $event->queries[ $key ] = $value;
453 453
                     }
454 454
                 }
455 455
             );
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
             Event::on(
460 460
                 Schema::class,
461 461
                 AlterSchemaFields::EVENT,
462
-                [GetCraftQLSchema::class, 'handle']
462
+                [ GetCraftQLSchema::class, 'handle' ]
463 463
             );
464 464
         }
465 465
     }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         Event::on(
474 474
             UrlManager::class,
475 475
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
476
-            function (RegisterUrlRulesEvent $event) {
476
+            function(RegisterUrlRulesEvent $event) {
477 477
                 Craft::debug(
478 478
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
479 479
                     __METHOD__
@@ -496,15 +496,15 @@  discard block
 block discarded – undo
496 496
         Event::on(
497 497
             Dashboard::class,
498 498
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
499
-            function (RegisterComponentTypesEvent $event) {
500
-                $event->types[] = RetourWidget::class;
499
+            function(RegisterComponentTypesEvent $event) {
500
+                $event->types[ ] = RetourWidget::class;
501 501
             }
502 502
         );
503 503
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
504 504
         Event::on(
505 505
             UrlManager::class,
506 506
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
507
-            function (RegisterUrlRulesEvent $event) {
507
+            function(RegisterUrlRulesEvent $event) {
508 508
                 Craft::debug(
509 509
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
510 510
                     __METHOD__
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
         Event::on(
521 521
             UserPermissions::class,
522 522
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
523
-            function (RegisterUserPermissionsEvent $event) {
523
+            function(RegisterUserPermissionsEvent $event) {
524 524
                 Craft::debug(
525 525
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
526 526
                     __METHOD__
527 527
                 );
528 528
                 // Register our custom permissions
529
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
529
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
530 530
             }
531 531
         );
532 532
     }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         Event::on(
543 543
             ErrorHandler::class,
544 544
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
545
-            function (ExceptionEvent $event) {
545
+            function(ExceptionEvent $event) {
546 546
                 Craft::debug(
547 547
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
548 548
                     __METHOD__
@@ -585,16 +585,16 @@  discard block
 block discarded – undo
585 585
     protected function handleElementUriChange(Element $element)
586 586
     {
587 587
         $uris = $this->getAllElementUris($element);
588
-        if (!empty($this->oldElementUris[$element->id])) {
589
-            $oldElementUris = $this->oldElementUris[$element->id];
588
+        if (!empty($this->oldElementUris[ $element->id ])) {
589
+            $oldElementUris = $this->oldElementUris[ $element->id ];
590 590
             foreach ($uris as $siteId => $newUri) {
591
-                if (!empty($oldElementUris[$siteId])) {
592
-                    $oldUri = $oldElementUris[$siteId];
591
+                if (!empty($oldElementUris[ $siteId ])) {
592
+                    $oldUri = $oldElementUris[ $siteId ];
593 593
                     Craft::debug(
594 594
                         Craft::t(
595 595
                             'retour',
596 596
                             'Comparing old: {oldUri} to new: {newUri}',
597
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
597
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
598 598
                         ),
599 599
                         __METHOD__
600 600
                     );
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
                         if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') {
615 615
                             try {
616 616
                                 if ($redirectSiteId !== null) {
617
-                                    $redirectSiteId = (int)$redirectSiteId;
617
+                                    $redirectSiteId = (int) $redirectSiteId;
618 618
                                 }
619 619
                                 $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId);
620 620
                                 $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId);
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
      */
648 648
     protected function getAllElementUris(Element $element): array
649 649
     {
650
-        $uris = [];
650
+        $uris = [ ];
651 651
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
652 652
             $sites = Craft::$app->getSites()->getAllSites();
653 653
             foreach ($sites as $site) {
654 654
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
655 655
                 if ($uri !== null) {
656
-                    $uris[$site->id] = $uri;
656
+                    $uris[ $site->id ] = $uri;
657 657
                 }
658 658
             }
659 659
         }
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
             Craft::t(
663 663
                 'retour',
664 664
                 'Getting Element URIs: {uris}',
665
-                ['uris' => print_r($uris, true)]
665
+                [ 'uris' => print_r($uris, true) ]
666 666
             ),
667 667
             __METHOD__
668 668
         );
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
             [
718 718
                 'key' => 'retour-redirect-caches',
719 719
                 'label' => Craft::t('retour', 'Retour redirect caches'),
720
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
720
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
721 721
             ],
722 722
         ];
723 723
     }
Please login to merge, or discard this patch.