Passed
Push — develop ( 147855...ea0405 )
by Andrew
04:35
created
src/Retour.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * @var array The URIs for the element before it was saved
96 96
      */
97
-    public $oldElementUris = [];
97
+    public $oldElementUris = [ ];
98 98
 
99 99
     // Public Methods
100 100
     // =========================================================================
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             Craft::t(
125 125
                 'retour',
126 126
                 '{name} plugin loaded',
127
-                ['name' => $this->name]
127
+                [ 'name' => $this->name ]
128 128
             ),
129 129
             __METHOD__
130 130
         );
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function getCpNavItem()
146 146
     {
147
-        $subNavs = [];
147
+        $subNavs = [ ];
148 148
         $navItem = parent::getCpNavItem();
149 149
         $currentUser = Craft::$app->getUser()->getIdentity();
150 150
         // Only show sub-navs the user has permission to view
151 151
         if ($currentUser->can('retour:dashboard')) {
152
-            $subNavs['dashboard'] = [
152
+            $subNavs[ 'dashboard' ] = [
153 153
                 'label' => 'Dashboard',
154 154
                 'url' => 'retour/dashboard',
155 155
             ];
156 156
         }
157 157
         if ($currentUser->can('retour:redirects')) {
158
-            $subNavs['redirects'] = [
158
+            $subNavs[ 'redirects' ] = [
159 159
                 'label' => 'Redirects',
160 160
                 'url' => 'retour/redirects',
161 161
             ];
162 162
         }
163 163
         if ($currentUser->can('retour:settings')) {
164
-            $subNavs['settings'] = [
164
+            $subNavs[ 'settings' ] = [
165 165
                 'label' => 'Settings',
166 166
                 'url' => 'retour/settings',
167 167
             ];
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         Event::on(
221 221
             ClearCaches::class,
222 222
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
223
-            function (RegisterCacheOptionsEvent $event) {
223
+            function(RegisterCacheOptionsEvent $event) {
224 224
                 Craft::debug(
225 225
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
226 226
                     __METHOD__
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
         Event::on(
237 237
             Plugins::class,
238 238
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
239
-            function (PluginEvent $event) {
239
+            function(PluginEvent $event) {
240 240
                 if ($event->plugin === $this) {
241 241
                     // Invalidate our caches after we've been installed
242 242
                     $this->clearAllCaches();
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         Event::on(
264 264
             CraftVariable::class,
265 265
             CraftVariable::EVENT_INIT,
266
-            function (Event $event) {
266
+            function(Event $event) {
267 267
                 /** @var CraftVariable $variable */
268 268
                 $variable = $event->sender;
269 269
                 $variable->set('retour', RetourVariable::class);
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         Event::on(
274 274
             Elements::class,
275 275
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
276
-            function (ElementEvent $event) {
276
+            function(ElementEvent $event) {
277 277
                 Craft::debug(
278 278
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
279 279
                     __METHOD__
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
                         if ($oldElement !== null) {
289 289
                             // Stash the old URLs by element id, and do so only once,
290 290
                             // in case we are called more than once per request
291
-                            if (empty($this->oldElementUris[$oldElement->id])) {
292
-                                $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement);
291
+                            if (empty($this->oldElementUris[ $oldElement->id ])) {
292
+                                $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement);
293 293
                             }
294 294
                         }
295 295
                     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         Event::on(
301 301
             Elements::class,
302 302
             Elements::EVENT_AFTER_SAVE_ELEMENT,
303
-            function (ElementEvent $event) {
303
+            function(ElementEvent $event) {
304 304
                 Craft::debug(
305 305
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
306 306
                     __METHOD__
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         Event::on(
317 317
             Plugins::class,
318 318
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
319
-            function () {
319
+            function() {
320 320
                 // Install these only after all other plugins have loaded
321 321
                 $request = Craft::$app->getRequest();
322 322
                 // Only respond to non-console site requests
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         Event::on(
341 341
             UrlManager::class,
342 342
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
343
-            function (RegisterUrlRulesEvent $event) {
343
+            function(RegisterUrlRulesEvent $event) {
344 344
                 Craft::debug(
345 345
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
346 346
                     __METHOD__
@@ -363,15 +363,15 @@  discard block
 block discarded – undo
363 363
         Event::on(
364 364
             Dashboard::class,
365 365
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
366
-            function (RegisterComponentTypesEvent $event) {
367
-                $event->types[] = RetourWidget::class;
366
+            function(RegisterComponentTypesEvent $event) {
367
+                $event->types[ ] = RetourWidget::class;
368 368
             }
369 369
         );
370 370
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
371 371
         Event::on(
372 372
             UrlManager::class,
373 373
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
374
-            function (RegisterUrlRulesEvent $event) {
374
+            function(RegisterUrlRulesEvent $event) {
375 375
                 Craft::debug(
376 376
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
377 377
                     __METHOD__
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
         Event::on(
388 388
             UserPermissions::class,
389 389
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
390
-            function (RegisterUserPermissionsEvent $event) {
390
+            function(RegisterUserPermissionsEvent $event) {
391 391
                 Craft::debug(
392 392
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
393 393
                     __METHOD__
394 394
                 );
395 395
                 // Register our custom permissions
396
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
396
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
397 397
             }
398 398
         );
399 399
     }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
         Event::on(
410 410
             ErrorHandler::class,
411 411
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
412
-            function (ExceptionEvent $event) {
412
+            function(ExceptionEvent $event) {
413 413
                 Craft::debug(
414 414
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
415 415
                     __METHOD__
@@ -452,16 +452,16 @@  discard block
 block discarded – undo
452 452
     protected function handleElementUriChange(Element $element)
453 453
     {
454 454
         $uris = $this->getAllElementUris($element);
455
-        if (!empty($this->oldElementUris[$element->id])) {
456
-            $oldElementUris = $this->oldElementUris[$element->id];
455
+        if (!empty($this->oldElementUris[ $element->id ])) {
456
+            $oldElementUris = $this->oldElementUris[ $element->id ];
457 457
             foreach ($uris as $siteId => $newUri) {
458
-                if (!empty($oldElementUris[$siteId])) {
459
-                    $oldUri = $oldElementUris[$siteId];
458
+                if (!empty($oldElementUris[ $siteId ])) {
459
+                    $oldUri = $oldElementUris[ $siteId ];
460 460
                     Craft::debug(
461 461
                         Craft::t(
462 462
                             'retour',
463 463
                             'Comparing old: {oldUri} to new: {newUri}',
464
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
464
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
465 465
                         ),
466 466
                         __METHOD__
467 467
                     );
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
      */
497 497
     protected function getAllElementUris(Element $element): array
498 498
     {
499
-        $uris = [];
499
+        $uris = [ ];
500 500
         $sites = Craft::$app->getSites()->getAllSites();
501 501
         foreach ($sites as $site) {
502 502
             $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
503 503
             if ($uri !== null) {
504
-                $uris[$site->id] = $uri;
504
+                $uris[ $site->id ] = $uri;
505 505
             }
506 506
         }
507 507
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
             Craft::t(
510 510
                 'retour',
511 511
                 'Getting Element URIs: {uris}',
512
-                ['uris' => print_r($uris, true)]
512
+                [ 'uris' => print_r($uris, true) ]
513 513
             ),
514 514
             __METHOD__
515 515
         );
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
             [
574 574
                 'key' => 'retour-redirect-caches',
575 575
                 'label' => Craft::t('retour', 'Retour redirect caches'),
576
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
576
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
577 577
             ],
578 578
         ];
579 579
     }
Please login to merge, or discard this patch.