Passed
Push — develop ( c3c610...674ca0 )
by Andrew
06:01
created
src/Retour.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     /**
111 111
      * @var array The URIs for the element before it was saved
112 112
      */
113
-    public $oldElementUris = [];
113
+    public $oldElementUris = [ ];
114 114
 
115 115
     // Public Methods
116 116
     // =========================================================================
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             Craft::t(
143 143
                 'retour',
144 144
                 '{name} plugin loaded',
145
-                ['name' => $this->name]
145
+                [ 'name' => $this->name ]
146 146
             ),
147 147
             __METHOD__
148 148
         );
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function getCpNavItem()
164 164
     {
165
-        $subNavs = [];
165
+        $subNavs = [ ];
166 166
         $navItem = parent::getCpNavItem();
167 167
         $currentUser = Craft::$app->getUser()->getIdentity();
168 168
         // Only show sub-navs the user has permission to view
169 169
         if ($currentUser->can('retour:dashboard')) {
170
-            $subNavs['dashboard'] = [
170
+            $subNavs[ 'dashboard' ] = [
171 171
                 'label' => 'Dashboard',
172 172
                 'url' => 'retour/dashboard',
173 173
             ];
174 174
         }
175 175
         if ($currentUser->can('retour:redirects')) {
176
-            $subNavs['redirects'] = [
176
+            $subNavs[ 'redirects' ] = [
177 177
                 'label' => 'Redirects',
178 178
                 'url' => 'retour/redirects',
179 179
             ];
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             $editableSettings = false;
185 185
         }
186 186
         if ($currentUser->can('retour:settings') && $editableSettings) {
187
-            $subNavs['settings'] = [
187
+            $subNavs[ 'settings' ] = [
188 188
                 'label' => 'Settings',
189 189
                 'url' => 'retour/settings',
190 190
             ];
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         Event::on(
244 244
             ClearCaches::class,
245 245
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
246
-            function (RegisterCacheOptionsEvent $event) {
246
+            function(RegisterCacheOptionsEvent $event) {
247 247
                 Craft::debug(
248 248
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
249 249
                     __METHOD__
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         Event::on(
260 260
             Plugins::class,
261 261
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
262
-            function (PluginEvent $event) {
262
+            function(PluginEvent $event) {
263 263
                 if ($event->plugin === $this) {
264 264
                     // Invalidate our caches after we've been installed
265 265
                     $this->clearAllCaches();
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         Event::on(
287 287
             CraftVariable::class,
288 288
             CraftVariable::EVENT_INIT,
289
-            function (Event $event) {
289
+            function(Event $event) {
290 290
                 /** @var CraftVariable $variable */
291 291
                 $variable = $event->sender;
292 292
                 $variable->set('retour', RetourVariable::class);
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
         Event::on(
297 297
             Elements::class,
298 298
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
299
-            function (ElementEvent $event) {
299
+            function(ElementEvent $event) {
300 300
                 Craft::debug(
301 301
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
302 302
                     __METHOD__
303 303
                 );
304 304
                 /** @var Element $element */
305 305
                 $element = $event->element;
306
-                if ($element !== null && $element->getUrl() !== null  && !$element->propagating) {
306
+                if ($element !== null && $element->getUrl() !== null && !$element->propagating) {
307 307
                     $checkElementSlug = true;
308 308
                     if (Retour::$craft32 && (
309 309
                             $element->resaving ||
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
                         if ($oldElement !== null && $oldElement->getUrl() !== null) {
323 323
                             // Stash the old URLs by element id, and do so only once,
324 324
                             // in case we are called more than once per request
325
-                            if (empty($this->oldElementUris[$oldElement->id])) {
326
-                                $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement);
325
+                            if (empty($this->oldElementUris[ $oldElement->id ])) {
326
+                                $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement);
327 327
                             }
328 328
                         }
329 329
                     }
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         Event::on(
335 335
             Elements::class,
336 336
             Elements::EVENT_AFTER_SAVE_ELEMENT,
337
-            function (ElementEvent $event) {
337
+            function(ElementEvent $event) {
338 338
                 Craft::debug(
339 339
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
340 340
                     __METHOD__
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         Event::on(
357 357
             Plugins::class,
358 358
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
359
-            function () {
359
+            function() {
360 360
                 // Install these only after all other plugins have loaded
361 361
                 $request = Craft::$app->getRequest();
362 362
                 // Only respond to non-console site requests
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
             Event::on(
375 375
                 Schema::class,
376 376
                 AlterSchemaFields::EVENT,
377
-                [GetCraftQLSchema::class, 'handle']
377
+                [ GetCraftQLSchema::class, 'handle' ]
378 378
             );
379 379
         }
380 380
     }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
         Event::on(
389 389
             UrlManager::class,
390 390
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
391
-            function (RegisterUrlRulesEvent $event) {
391
+            function(RegisterUrlRulesEvent $event) {
392 392
                 Craft::debug(
393 393
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
394 394
                     __METHOD__
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
         Event::on(
412 412
             Dashboard::class,
413 413
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
414
-            function (RegisterComponentTypesEvent $event) {
415
-                $event->types[] = RetourWidget::class;
414
+            function(RegisterComponentTypesEvent $event) {
415
+                $event->types[ ] = RetourWidget::class;
416 416
             }
417 417
         );
418 418
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
419 419
         Event::on(
420 420
             UrlManager::class,
421 421
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
422
-            function (RegisterUrlRulesEvent $event) {
422
+            function(RegisterUrlRulesEvent $event) {
423 423
                 Craft::debug(
424 424
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
425 425
                     __METHOD__
@@ -435,13 +435,13 @@  discard block
 block discarded – undo
435 435
         Event::on(
436 436
             UserPermissions::class,
437 437
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
438
-            function (RegisterUserPermissionsEvent $event) {
438
+            function(RegisterUserPermissionsEvent $event) {
439 439
                 Craft::debug(
440 440
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
441 441
                     __METHOD__
442 442
                 );
443 443
                 // Register our custom permissions
444
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
444
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
445 445
             }
446 446
         );
447 447
     }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
         Event::on(
458 458
             ErrorHandler::class,
459 459
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
460
-            function (ExceptionEvent $event) {
460
+            function(ExceptionEvent $event) {
461 461
                 Craft::debug(
462 462
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
463 463
                     __METHOD__
@@ -500,16 +500,16 @@  discard block
 block discarded – undo
500 500
     protected function handleElementUriChange(Element $element)
501 501
     {
502 502
         $uris = $this->getAllElementUris($element);
503
-        if (!empty($this->oldElementUris[$element->id])) {
504
-            $oldElementUris = $this->oldElementUris[$element->id];
503
+        if (!empty($this->oldElementUris[ $element->id ])) {
504
+            $oldElementUris = $this->oldElementUris[ $element->id ];
505 505
             foreach ($uris as $siteId => $newUri) {
506
-                if (!empty($oldElementUris[$siteId])) {
507
-                    $oldUri = $oldElementUris[$siteId];
506
+                if (!empty($oldElementUris[ $siteId ])) {
507
+                    $oldUri = $oldElementUris[ $siteId ];
508 508
                     Craft::debug(
509 509
                         Craft::t(
510 510
                             'retour',
511 511
                             'Comparing old: {oldUri} to new: {newUri}',
512
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
512
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
513 513
                         ),
514 514
                         __METHOD__
515 515
                     );
@@ -549,13 +549,13 @@  discard block
 block discarded – undo
549 549
      */
550 550
     protected function getAllElementUris(Element $element): array
551 551
     {
552
-        $uris = [];
552
+        $uris = [ ];
553 553
         if (!ElementHelper::isDraftOrRevision($element)) {
554 554
             $sites = Craft::$app->getSites()->getAllSites();
555 555
             foreach ($sites as $site) {
556 556
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
557 557
                 if ($uri !== null) {
558
-                    $uris[$site->id] = $uri;
558
+                    $uris[ $site->id ] = $uri;
559 559
                 }
560 560
             }
561 561
         }
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
             Craft::t(
565 565
                 'retour',
566 566
                 'Getting Element URIs: {uris}',
567
-                ['uris' => print_r($uris, true)]
567
+                [ 'uris' => print_r($uris, true) ]
568 568
             ),
569 569
             __METHOD__
570 570
         );
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
             [
629 629
                 'key' => 'retour-redirect-caches',
630 630
                 'label' => Craft::t('retour', 'Retour redirect caches'),
631
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
631
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
632 632
             ],
633 633
         ];
634 634
     }
Please login to merge, or discard this patch.