Passed
Push — develop ( 99c898...3d7a2e )
by Andrew
08:24
created
src/Retour.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * @var array The URIs for the element before it was saved
127 127
      */
128
-    public $oldElementUris = [];
128
+    public $oldElementUris = [ ];
129 129
 
130 130
     // Public Methods
131 131
     // =========================================================================
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             Craft::t(
159 159
                 'retour',
160 160
                 '{name} plugin loaded',
161
-                ['name' => $this->name]
161
+                [ 'name' => $this->name ]
162 162
             ),
163 163
             __METHOD__
164 164
         );
@@ -178,18 +178,18 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function getCpNavItem()
180 180
     {
181
-        $subNavs = [];
181
+        $subNavs = [ ];
182 182
         $navItem = parent::getCpNavItem();
183 183
         $currentUser = Craft::$app->getUser()->getIdentity();
184 184
         // Only show sub-navs the user has permission to view
185 185
         if ($currentUser->can('retour:dashboard')) {
186
-            $subNavs['dashboard'] = [
186
+            $subNavs[ 'dashboard' ] = [
187 187
                 'label' => 'Dashboard',
188 188
                 'url' => 'retour/dashboard',
189 189
             ];
190 190
         }
191 191
         if ($currentUser->can('retour:redirects')) {
192
-            $subNavs['redirects'] = [
192
+            $subNavs[ 'redirects' ] = [
193 193
                 'label' => 'Redirects',
194 194
                 'url' => 'retour/redirects',
195 195
             ];
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             $editableSettings = false;
201 201
         }
202 202
         if ($currentUser->can('retour:settings') && $editableSettings) {
203
-            $subNavs['settings'] = [
203
+            $subNavs[ 'settings' ] = [
204 204
                 'label' => 'Settings',
205 205
                 'url' => 'retour/settings',
206 206
             ];
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         Event::on(
260 260
             ClearCaches::class,
261 261
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
262
-            function (RegisterCacheOptionsEvent $event) {
262
+            function(RegisterCacheOptionsEvent $event) {
263 263
                 Craft::debug(
264 264
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
265 265
                     __METHOD__
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         Event::on(
276 276
             Plugins::class,
277 277
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
278
-            function (PluginEvent $event) {
278
+            function(PluginEvent $event) {
279 279
                 if ($event->plugin === $this) {
280 280
                     // Invalidate our caches after we've been installed
281 281
                     $this->clearAllCaches();
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         Event::on(
311 311
             CraftVariable::class,
312 312
             CraftVariable::EVENT_INIT,
313
-            function (Event $event) {
313
+            function(Event $event) {
314 314
                 /** @var CraftVariable $variable */
315 315
                 $variable = $event->sender;
316 316
                 $variable->set('retour', [
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         Event::on(
324 324
             Elements::class,
325 325
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
326
-            function (ElementEvent $event) {
326
+            function(ElementEvent $event) {
327 327
                 Craft::debug(
328 328
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
329 329
                     __METHOD__
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
349 349
                             // Stash the old URLs by element id, and do so only once,
350 350
                             // in case we are called more than once per request
351
-                            if (empty($this->oldElementUris[$element->id])) {
352
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
351
+                            if (empty($this->oldElementUris[ $element->id ])) {
352
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
353 353
                             }
354 354
                         }
355 355
                     }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
         Event::on(
361 361
             Elements::class,
362 362
             Elements::EVENT_AFTER_SAVE_ELEMENT,
363
-            function (ElementEvent $event) {
363
+            function(ElementEvent $event) {
364 364
                 Craft::debug(
365 365
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
366 366
                     __METHOD__
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         Event::on(
383 383
             Plugins::class,
384 384
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
385
-            function () {
385
+            function() {
386 386
                 // Install these only after all other plugins have loaded
387 387
                 $request = Craft::$app->getRequest();
388 388
                 // Only respond to non-console site requests
@@ -400,26 +400,26 @@  discard block
 block discarded – undo
400 400
             Event::on(
401 401
                 Gql::class,
402 402
                 Gql::EVENT_REGISTER_GQL_TYPES,
403
-                function (RegisterGqlTypesEvent $event) {
403
+                function(RegisterGqlTypesEvent $event) {
404 404
                     Craft::debug(
405 405
                         'Gql::EVENT_REGISTER_GQL_TYPES',
406 406
                         __METHOD__
407 407
                     );
408
-                    $event->types[] = RetourInterface::class;
408
+                    $event->types[ ] = RetourInterface::class;
409 409
                 }
410 410
             );
411 411
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
412 412
             Event::on(
413 413
                 Gql::class,
414 414
                 Gql::EVENT_REGISTER_GQL_QUERIES,
415
-                function (RegisterGqlQueriesEvent $event) {
415
+                function(RegisterGqlQueriesEvent $event) {
416 416
                     Craft::debug(
417 417
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
418 418
                         __METHOD__
419 419
                     );
420 420
                     $queries = RetourQuery::getQueries();
421 421
                     foreach ($queries as $key => $value) {
422
-                        $event->queries[$key] = $value;
422
+                        $event->queries[ $key ] = $value;
423 423
                     }
424 424
                 }
425 425
             );
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             Event::on(
430 430
                 Schema::class,
431 431
                 AlterSchemaFields::EVENT,
432
-                [GetCraftQLSchema::class, 'handle']
432
+                [ GetCraftQLSchema::class, 'handle' ]
433 433
             );
434 434
         }
435 435
     }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         Event::on(
444 444
             UrlManager::class,
445 445
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
446
-            function (RegisterUrlRulesEvent $event) {
446
+            function(RegisterUrlRulesEvent $event) {
447 447
                 Craft::debug(
448 448
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
449 449
                     __METHOD__
@@ -466,15 +466,15 @@  discard block
 block discarded – undo
466 466
         Event::on(
467 467
             Dashboard::class,
468 468
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
469
-            function (RegisterComponentTypesEvent $event) {
470
-                $event->types[] = RetourWidget::class;
469
+            function(RegisterComponentTypesEvent $event) {
470
+                $event->types[ ] = RetourWidget::class;
471 471
             }
472 472
         );
473 473
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
474 474
         Event::on(
475 475
             UrlManager::class,
476 476
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
477
-            function (RegisterUrlRulesEvent $event) {
477
+            function(RegisterUrlRulesEvent $event) {
478 478
                 Craft::debug(
479 479
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
480 480
                     __METHOD__
@@ -490,13 +490,13 @@  discard block
 block discarded – undo
490 490
         Event::on(
491 491
             UserPermissions::class,
492 492
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
493
-            function (RegisterUserPermissionsEvent $event) {
493
+            function(RegisterUserPermissionsEvent $event) {
494 494
                 Craft::debug(
495 495
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
496 496
                     __METHOD__
497 497
                 );
498 498
                 // Register our custom permissions
499
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
499
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
500 500
             }
501 501
         );
502 502
     }
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         Event::on(
513 513
             ErrorHandler::class,
514 514
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
515
-            function (ExceptionEvent $event) {
515
+            function(ExceptionEvent $event) {
516 516
                 Craft::debug(
517 517
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
518 518
                     __METHOD__
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
     protected function handleElementUriChange(Element $element)
556 556
     {
557 557
         $uris = $this->getAllElementUris($element);
558
-        if (!empty($this->oldElementUris[$element->id])) {
559
-            $oldElementUris = $this->oldElementUris[$element->id];
558
+        if (!empty($this->oldElementUris[ $element->id ])) {
559
+            $oldElementUris = $this->oldElementUris[ $element->id ];
560 560
             foreach ($uris as $siteId => $newUri) {
561
-                if (!empty($oldElementUris[$siteId])) {
562
-                    $oldUri = $oldElementUris[$siteId];
561
+                if (!empty($oldElementUris[ $siteId ])) {
562
+                    $oldUri = $oldElementUris[ $siteId ];
563 563
                     Craft::debug(
564 564
                         Craft::t(
565 565
                             'retour',
566 566
                             'Comparing old: {oldUri} to new: {newUri}',
567
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
567
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
568 568
                         ),
569 569
                         __METHOD__
570 570
                     );
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
                         if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') {
585 585
                             try {
586 586
                                 if ($redirectSiteId !== null) {
587
-                                    $redirectSiteId = (int)$redirectSiteId;
587
+                                    $redirectSiteId = (int) $redirectSiteId;
588 588
                                 }
589 589
                                 $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId);
590 590
                                 $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId);
@@ -617,13 +617,13 @@  discard block
 block discarded – undo
617 617
      */
618 618
     protected function getAllElementUris(Element $element): array
619 619
     {
620
-        $uris = [];
620
+        $uris = [ ];
621 621
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
622 622
             $sites = Craft::$app->getSites()->getAllSites();
623 623
             foreach ($sites as $site) {
624 624
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
625 625
                 if ($uri !== null) {
626
-                    $uris[$site->id] = $uri;
626
+                    $uris[ $site->id ] = $uri;
627 627
                 }
628 628
             }
629 629
         }
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             Craft::t(
633 633
                 'retour',
634 634
                 'Getting Element URIs: {uris}',
635
-                ['uris' => print_r($uris, true)]
635
+                [ 'uris' => print_r($uris, true) ]
636 636
             ),
637 637
             __METHOD__
638 638
         );
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
             [
688 688
                 'key' => 'retour-redirect-caches',
689 689
                 'label' => Craft::t('retour', 'Retour redirect caches'),
690
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
690
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
691 691
             ],
692 692
         ];
693 693
     }
Please login to merge, or discard this patch.