Passed
Push — develop ( 0b0eed...aa8cda )
by Andrew
07:05
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
         ];
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     /**
151 151
      * @var array The URIs for the element before it was saved
152 152
      */
153
-    public $oldElementUris = [];
153
+    public $oldElementUris = [ ];
154 154
 
155 155
     // Public Methods
156 156
     // =========================================================================
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             Craft::t(
184 184
                 'retour',
185 185
                 '{name} plugin loaded',
186
-                ['name' => $this->name]
186
+                [ 'name' => $this->name ]
187 187
             ),
188 188
             __METHOD__
189 189
         );
@@ -203,18 +203,18 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function getCpNavItem()
205 205
     {
206
-        $subNavs = [];
206
+        $subNavs = [ ];
207 207
         $navItem = parent::getCpNavItem();
208 208
         $currentUser = Craft::$app->getUser()->getIdentity();
209 209
         // Only show sub-navs the user has permission to view
210 210
         if ($currentUser->can('retour:dashboard')) {
211
-            $subNavs['dashboard'] = [
211
+            $subNavs[ 'dashboard' ] = [
212 212
                 'label' => 'Dashboard',
213 213
                 'url' => 'retour/dashboard',
214 214
             ];
215 215
         }
216 216
         if ($currentUser->can('retour:redirects')) {
217
-            $subNavs['redirects'] = [
217
+            $subNavs[ 'redirects' ] = [
218 218
                 'label' => 'Redirects',
219 219
                 'url' => 'retour/redirects',
220 220
             ];
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             $editableSettings = false;
226 226
         }
227 227
         if ($currentUser->can('retour:settings') && $editableSettings) {
228
-            $subNavs['settings'] = [
228
+            $subNavs[ 'settings' ] = [
229 229
                 'label' => 'Settings',
230 230
                 'url' => 'retour/settings',
231 231
             ];
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         Event::on(
285 285
             ClearCaches::class,
286 286
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
287
-            function (RegisterCacheOptionsEvent $event) {
287
+            function(RegisterCacheOptionsEvent $event) {
288 288
                 Craft::debug(
289 289
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
290 290
                     __METHOD__
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         Event::on(
301 301
             Plugins::class,
302 302
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
303
-            function (PluginEvent $event) {
303
+            function(PluginEvent $event) {
304 304
                 if ($event->plugin === $this) {
305 305
                     // Invalidate our caches after we've been installed
306 306
                     $this->clearAllCaches();
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         Event::on(
336 336
             CraftVariable::class,
337 337
             CraftVariable::EVENT_INIT,
338
-            function (Event $event) {
338
+            function(Event $event) {
339 339
                 /** @var CraftVariable $variable */
340 340
                 $variable = $event->sender;
341 341
                 $variable->set('retour', [
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         Event::on(
349 349
             Elements::class,
350 350
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
351
-            function (ElementEvent $event) {
351
+            function(ElementEvent $event) {
352 352
                 Craft::debug(
353 353
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
354 354
                     __METHOD__
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
372 372
                             // Stash the old URLs by element id, and do so only once,
373 373
                             // in case we are called more than once per request
374
-                            if (empty($this->oldElementUris[$element->id])) {
375
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
374
+                            if (empty($this->oldElementUris[ $element->id ])) {
375
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
376 376
                             }
377 377
                         }
378 378
                     }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         Event::on(
384 384
             Elements::class,
385 385
             Elements::EVENT_AFTER_SAVE_ELEMENT,
386
-            function (ElementEvent $event) {
386
+            function(ElementEvent $event) {
387 387
                 Craft::debug(
388 388
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
389 389
                     __METHOD__
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
         Event::on(
406 406
             Plugins::class,
407 407
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
408
-            function () {
408
+            function() {
409 409
                 // Install these only after all other plugins have loaded
410 410
                 $request = Craft::$app->getRequest();
411 411
                 // Only respond to non-console site requests
@@ -423,26 +423,26 @@  discard block
 block discarded – undo
423 423
             Event::on(
424 424
                 Gql::class,
425 425
                 Gql::EVENT_REGISTER_GQL_TYPES,
426
-                function (RegisterGqlTypesEvent $event) {
426
+                function(RegisterGqlTypesEvent $event) {
427 427
                     Craft::debug(
428 428
                         'Gql::EVENT_REGISTER_GQL_TYPES',
429 429
                         __METHOD__
430 430
                     );
431
-                    $event->types[] = RetourInterface::class;
431
+                    $event->types[ ] = RetourInterface::class;
432 432
                 }
433 433
             );
434 434
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
435 435
             Event::on(
436 436
                 Gql::class,
437 437
                 Gql::EVENT_REGISTER_GQL_QUERIES,
438
-                function (RegisterGqlQueriesEvent $event) {
438
+                function(RegisterGqlQueriesEvent $event) {
439 439
                     Craft::debug(
440 440
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
441 441
                         __METHOD__
442 442
                     );
443 443
                     $queries = RetourQuery::getQueries();
444 444
                     foreach ($queries as $key => $value) {
445
-                        $event->queries[$key] = $value;
445
+                        $event->queries[ $key ] = $value;
446 446
                     }
447 447
                 }
448 448
             );
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
             Event::on(
453 453
                 Schema::class,
454 454
                 AlterSchemaFields::EVENT,
455
-                [GetCraftQLSchema::class, 'handle']
455
+                [ GetCraftQLSchema::class, 'handle' ]
456 456
             );
457 457
         }
458 458
     }
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         Event::on(
467 467
             UrlManager::class,
468 468
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
469
-            function (RegisterUrlRulesEvent $event) {
469
+            function(RegisterUrlRulesEvent $event) {
470 470
                 Craft::debug(
471 471
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
472 472
                     __METHOD__
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
         Event::on(
490 490
             Dashboard::class,
491 491
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
492
-            function (RegisterComponentTypesEvent $event) {
493
-                $event->types[] = RetourWidget::class;
492
+            function(RegisterComponentTypesEvent $event) {
493
+                $event->types[ ] = RetourWidget::class;
494 494
             }
495 495
         );
496 496
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
497 497
         Event::on(
498 498
             UrlManager::class,
499 499
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
500
-            function (RegisterUrlRulesEvent $event) {
500
+            function(RegisterUrlRulesEvent $event) {
501 501
                 Craft::debug(
502 502
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
503 503
                     __METHOD__
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
         Event::on(
514 514
             UserPermissions::class,
515 515
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
516
-            function (RegisterUserPermissionsEvent $event) {
516
+            function(RegisterUserPermissionsEvent $event) {
517 517
                 Craft::debug(
518 518
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
519 519
                     __METHOD__
520 520
                 );
521 521
                 // Register our custom permissions
522
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
522
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
523 523
             }
524 524
         );
525 525
     }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
         Event::on(
536 536
             ErrorHandler::class,
537 537
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
538
-            function (ExceptionEvent $event) {
538
+            function(ExceptionEvent $event) {
539 539
                 Craft::debug(
540 540
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
541 541
                     __METHOD__
@@ -578,16 +578,16 @@  discard block
 block discarded – undo
578 578
     protected function handleElementUriChange(Element $element)
579 579
     {
580 580
         $uris = $this->getAllElementUris($element);
581
-        if (!empty($this->oldElementUris[$element->id])) {
582
-            $oldElementUris = $this->oldElementUris[$element->id];
581
+        if (!empty($this->oldElementUris[ $element->id ])) {
582
+            $oldElementUris = $this->oldElementUris[ $element->id ];
583 583
             foreach ($uris as $siteId => $newUri) {
584
-                if (!empty($oldElementUris[$siteId])) {
585
-                    $oldUri = $oldElementUris[$siteId];
584
+                if (!empty($oldElementUris[ $siteId ])) {
585
+                    $oldUri = $oldElementUris[ $siteId ];
586 586
                     Craft::debug(
587 587
                         Craft::t(
588 588
                             'retour',
589 589
                             'Comparing old: {oldUri} to new: {newUri}',
590
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
590
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
591 591
                         ),
592 592
                         __METHOD__
593 593
                     );
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                         if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') {
608 608
                             try {
609 609
                                 if ($redirectSiteId !== null) {
610
-                                    $redirectSiteId = (int)$redirectSiteId;
610
+                                    $redirectSiteId = (int) $redirectSiteId;
611 611
                                 }
612 612
                                 $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId);
613 613
                                 $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId);
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
      */
641 641
     protected function getAllElementUris(Element $element): array
642 642
     {
643
-        $uris = [];
643
+        $uris = [ ];
644 644
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
645 645
             $sites = Craft::$app->getSites()->getAllSites();
646 646
             foreach ($sites as $site) {
647 647
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
648 648
                 if ($uri !== null) {
649
-                    $uris[$site->id] = $uri;
649
+                    $uris[ $site->id ] = $uri;
650 650
                 }
651 651
             }
652 652
         }
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
             Craft::t(
656 656
                 'retour',
657 657
                 'Getting Element URIs: {uris}',
658
-                ['uris' => print_r($uris, true)]
658
+                [ 'uris' => print_r($uris, true) ]
659 659
             ),
660 660
             __METHOD__
661 661
         );
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
             [
711 711
                 'key' => 'retour-redirect-caches',
712 712
                 'label' => Craft::t('retour', 'Retour redirect caches'),
713
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
713
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
714 714
             ],
715 715
         ];
716 716
     }
Please login to merge, or discard this patch.