Passed
Push — develop ( 5da002...9e643f )
by Andrew
04:27
created
src/Retour.php 1 patch
Spacing   +31 added lines, -31 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,7 +296,7 @@  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__
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
                         if ($oldElement !== null) {
316 316
                             // Stash the old URLs by element id, and do so only once,
317 317
                             // in case we are called more than once per request
318
-                            if (empty($this->oldElementUris[$oldElement->id])) {
319
-                                $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement);
318
+                            if (empty($this->oldElementUris[ $oldElement->id ])) {
319
+                                $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement);
320 320
                             }
321 321
                         }
322 322
                     }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         Event::on(
328 328
             Elements::class,
329 329
             Elements::EVENT_AFTER_SAVE_ELEMENT,
330
-            function (ElementEvent $event) {
330
+            function(ElementEvent $event) {
331 331
                 Craft::debug(
332 332
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
333 333
                     __METHOD__
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         Event::on(
350 350
             Plugins::class,
351 351
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
352
-            function () {
352
+            function() {
353 353
                 // Install these only after all other plugins have loaded
354 354
                 $request = Craft::$app->getRequest();
355 355
                 // Only respond to non-console site requests
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
             Event::on(
368 368
                 Schema::class,
369 369
                 AlterSchemaFields::EVENT,
370
-                [GetCraftQLSchema::class, 'handle']
370
+                [ GetCraftQLSchema::class, 'handle' ]
371 371
             );
372 372
         }
373 373
     }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         Event::on(
382 382
             UrlManager::class,
383 383
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
384
-            function (RegisterUrlRulesEvent $event) {
384
+            function(RegisterUrlRulesEvent $event) {
385 385
                 Craft::debug(
386 386
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
387 387
                     __METHOD__
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
         Event::on(
405 405
             Dashboard::class,
406 406
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
407
-            function (RegisterComponentTypesEvent $event) {
408
-                $event->types[] = RetourWidget::class;
407
+            function(RegisterComponentTypesEvent $event) {
408
+                $event->types[ ] = RetourWidget::class;
409 409
             }
410 410
         );
411 411
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
412 412
         Event::on(
413 413
             UrlManager::class,
414 414
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
415
-            function (RegisterUrlRulesEvent $event) {
415
+            function(RegisterUrlRulesEvent $event) {
416 416
                 Craft::debug(
417 417
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
418 418
                     __METHOD__
@@ -428,13 +428,13 @@  discard block
 block discarded – undo
428 428
         Event::on(
429 429
             UserPermissions::class,
430 430
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
431
-            function (RegisterUserPermissionsEvent $event) {
431
+            function(RegisterUserPermissionsEvent $event) {
432 432
                 Craft::debug(
433 433
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
434 434
                     __METHOD__
435 435
                 );
436 436
                 // Register our custom permissions
437
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
437
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
438 438
             }
439 439
         );
440 440
     }
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         Event::on(
451 451
             ErrorHandler::class,
452 452
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
453
-            function (ExceptionEvent $event) {
453
+            function(ExceptionEvent $event) {
454 454
                 Craft::debug(
455 455
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
456 456
                     __METHOD__
@@ -493,16 +493,16 @@  discard block
 block discarded – undo
493 493
     protected function handleElementUriChange(Element $element)
494 494
     {
495 495
         $uris = $this->getAllElementUris($element);
496
-        if (!empty($this->oldElementUris[$element->id])) {
497
-            $oldElementUris = $this->oldElementUris[$element->id];
496
+        if (!empty($this->oldElementUris[ $element->id ])) {
497
+            $oldElementUris = $this->oldElementUris[ $element->id ];
498 498
             foreach ($uris as $siteId => $newUri) {
499
-                if (!empty($oldElementUris[$siteId])) {
500
-                    $oldUri = $oldElementUris[$siteId];
499
+                if (!empty($oldElementUris[ $siteId ])) {
500
+                    $oldUri = $oldElementUris[ $siteId ];
501 501
                     Craft::debug(
502 502
                         Craft::t(
503 503
                             'retour',
504 504
                             'Comparing old: {oldUri} to new: {newUri}',
505
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
505
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
506 506
                         ),
507 507
                         __METHOD__
508 508
                     );
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
      */
543 543
     protected function getAllElementUris(Element $element): array
544 544
     {
545
-        $uris = [];
545
+        $uris = [ ];
546 546
         if (!ElementHelper::isDraftOrRevision($element)) {
547 547
             $sites = Craft::$app->getSites()->getAllSites();
548 548
             foreach ($sites as $site) {
549 549
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
550 550
                 if ($uri !== null) {
551
-                    $uris[$site->id] = $uri;
551
+                    $uris[ $site->id ] = $uri;
552 552
                 }
553 553
             }
554 554
         }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
             Craft::t(
558 558
                 'retour',
559 559
                 'Getting Element URIs: {uris}',
560
-                ['uris' => print_r($uris, true)]
560
+                [ 'uris' => print_r($uris, true) ]
561 561
             ),
562 562
             __METHOD__
563 563
         );
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
             [
622 622
                 'key' => 'retour-redirect-caches',
623 623
                 'label' => Craft::t('retour', 'Retour redirect caches'),
624
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
624
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
625 625
             ],
626 626
         ];
627 627
     }
Please login to merge, or discard this patch.