Passed
Push — develop ( b4111b...cbcc38 )
by Andrew
21:43
created
src/models/Settings.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
     public function rules()
125 125
     {
126 126
         return [
127
-            ['pluginName', 'string'],
128
-            ['pluginName', 'default', 'value' => 'Retour'],
127
+            [ 'pluginName', 'string' ],
128
+            [ 'pluginName', 'default', 'value' => 'Retour' ],
129 129
             [
130 130
                 [
131 131
                     'createUriChangeRedirects',
@@ -136,23 +136,23 @@  discard block
 block discarded – undo
136 136
                 ],
137 137
                 'boolean',
138 138
             ],
139
-            ['uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly'],
140
-            ['uriChangeRedirectSrcMatch', 'string'],
141
-            ['uriChangeRedirectSrcMatch', 'in', 'range' => [
139
+            [ 'uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly' ],
140
+            [ 'uriChangeRedirectSrcMatch', 'string' ],
141
+            [ 'uriChangeRedirectSrcMatch', 'in', 'range' => [
142 142
                 'pathonly',
143 143
                 'fullurl'
144
-            ]],
145
-            ['staticRedirectDisplayLimit', 'integer', 'min' => 1],
146
-            ['staticRedirectDisplayLimit', 'default', 'value' => 100],
147
-            ['dynamicRedirectDisplayLimit', 'integer', 'min' => 1],
148
-            ['dynamicRedirectDisplayLimit', 'default', 'value' => 100],
149
-            ['statsStoredLimit', 'integer', 'min' => 1],
150
-            ['statsStoredLimit', 'default', 'value' => 1000],
151
-            ['refreshIntervalSecs', 'integer', 'min' => 0],
152
-            ['refreshIntervalSecs', 'default', 'value' => 3],
153
-            ['statsDisplayLimit', 'integer', 'min' => 1],
154
-            ['statsDisplayLimit', 'default', 'value' => 1000],
155
-            ['excludePatterns', ArrayValidator::class],
144
+            ] ],
145
+            [ 'staticRedirectDisplayLimit', 'integer', 'min' => 1 ],
146
+            [ 'staticRedirectDisplayLimit', 'default', 'value' => 100 ],
147
+            [ 'dynamicRedirectDisplayLimit', 'integer', 'min' => 1 ],
148
+            [ 'dynamicRedirectDisplayLimit', 'default', 'value' => 100 ],
149
+            [ 'statsStoredLimit', 'integer', 'min' => 1 ],
150
+            [ 'statsStoredLimit', 'default', 'value' => 1000 ],
151
+            [ 'refreshIntervalSecs', 'integer', 'min' => 0 ],
152
+            [ 'refreshIntervalSecs', 'default', 'value' => 3 ],
153
+            [ 'statsDisplayLimit', 'integer', 'min' => 1 ],
154
+            [ 'statsDisplayLimit', 'default', 'value' => 1000 ],
155
+            [ 'excludePatterns', ArrayValidator::class ],
156 156
         ];
157 157
     }
158 158
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function behaviors()
163 163
     {
164
-        $craft31Behaviors = [];
164
+        $craft31Behaviors = [ ];
165 165
         if (Retour::$craft31) {
166 166
             $craft31Behaviors = [
167 167
                 'parser' => [
Please login to merge, or discard this patch.
src/Retour.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     /**
122 122
      * @var array The URIs for the element before it was saved
123 123
      */
124
-    public $oldElementUris = [];
124
+    public $oldElementUris = [ ];
125 125
 
126 126
     // Public Methods
127 127
     // =========================================================================
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             Craft::t(
155 155
                 'retour',
156 156
                 '{name} plugin loaded',
157
-                ['name' => $this->name]
157
+                [ 'name' => $this->name ]
158 158
             ),
159 159
             __METHOD__
160 160
         );
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getCpNavItem()
176 176
     {
177
-        $subNavs = [];
177
+        $subNavs = [ ];
178 178
         $navItem = parent::getCpNavItem();
179 179
         $currentUser = Craft::$app->getUser()->getIdentity();
180 180
         // Only show sub-navs the user has permission to view
181 181
         if ($currentUser->can('retour:dashboard')) {
182
-            $subNavs['dashboard'] = [
182
+            $subNavs[ 'dashboard' ] = [
183 183
                 'label' => 'Dashboard',
184 184
                 'url' => 'retour/dashboard',
185 185
             ];
186 186
         }
187 187
         if ($currentUser->can('retour:redirects')) {
188
-            $subNavs['redirects'] = [
188
+            $subNavs[ 'redirects' ] = [
189 189
                 'label' => 'Redirects',
190 190
                 'url' => 'retour/redirects',
191 191
             ];
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             $editableSettings = false;
197 197
         }
198 198
         if ($currentUser->can('retour:settings') && $editableSettings) {
199
-            $subNavs['settings'] = [
199
+            $subNavs[ 'settings' ] = [
200 200
                 'label' => 'Settings',
201 201
                 'url' => 'retour/settings',
202 202
             ];
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         Event::on(
256 256
             ClearCaches::class,
257 257
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
258
-            function (RegisterCacheOptionsEvent $event) {
258
+            function(RegisterCacheOptionsEvent $event) {
259 259
                 Craft::debug(
260 260
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
261 261
                     __METHOD__
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         Event::on(
272 272
             Plugins::class,
273 273
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
274
-            function (PluginEvent $event) {
274
+            function(PluginEvent $event) {
275 275
                 if ($event->plugin === $this) {
276 276
                     // Invalidate our caches after we've been installed
277 277
                     $this->clearAllCaches();
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         Event::on(
299 299
             CraftVariable::class,
300 300
             CraftVariable::EVENT_INIT,
301
-            function (Event $event) {
301
+            function(Event $event) {
302 302
                 /** @var CraftVariable $variable */
303 303
                 $variable = $event->sender;
304 304
                 $variable->set('retour', RetourVariable::class);
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         Event::on(
309 309
             Elements::class,
310 310
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
311
-            function (ElementEvent $event) {
311
+            function(ElementEvent $event) {
312 312
                 Craft::debug(
313 313
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
314 314
                     __METHOD__
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
334 334
                             // Stash the old URLs by element id, and do so only once,
335 335
                             // in case we are called more than once per request
336
-                            if (empty($this->oldElementUris[$element->id])) {
337
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
336
+                            if (empty($this->oldElementUris[ $element->id ])) {
337
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
338 338
                             }
339 339
                         }
340 340
                     }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         Event::on(
346 346
             Elements::class,
347 347
             Elements::EVENT_AFTER_SAVE_ELEMENT,
348
-            function (ElementEvent $event) {
348
+            function(ElementEvent $event) {
349 349
                 Craft::debug(
350 350
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
351 351
                     __METHOD__
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         Event::on(
368 368
             Plugins::class,
369 369
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
370
-            function () {
370
+            function() {
371 371
                 // Install these only after all other plugins have loaded
372 372
                 $request = Craft::$app->getRequest();
373 373
                 // Only respond to non-console site requests
@@ -385,26 +385,26 @@  discard block
 block discarded – undo
385 385
             Event::on(
386 386
                 Gql::class,
387 387
                 Gql::EVENT_REGISTER_GQL_TYPES,
388
-                function (RegisterGqlTypesEvent $event) {
388
+                function(RegisterGqlTypesEvent $event) {
389 389
                     Craft::debug(
390 390
                         'Gql::EVENT_REGISTER_GQL_TYPES',
391 391
                         __METHOD__
392 392
                     );
393
-                    $event->types[] = RetourInterface::class;
393
+                    $event->types[ ] = RetourInterface::class;
394 394
                 }
395 395
             );
396 396
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
397 397
             Event::on(
398 398
                 Gql::class,
399 399
                 Gql::EVENT_REGISTER_GQL_QUERIES,
400
-                function (RegisterGqlQueriesEvent $event) {
400
+                function(RegisterGqlQueriesEvent $event) {
401 401
                     Craft::debug(
402 402
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
403 403
                         __METHOD__
404 404
                     );
405 405
                     $queries = RetourQuery::getQueries();
406 406
                     foreach ($queries as $key => $value) {
407
-                        $event->queries[$key] = $value;
407
+                        $event->queries[ $key ] = $value;
408 408
                     }
409 409
                 }
410 410
             );
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
             Event::on(
415 415
                 Schema::class,
416 416
                 AlterSchemaFields::EVENT,
417
-                [GetCraftQLSchema::class, 'handle']
417
+                [ GetCraftQLSchema::class, 'handle' ]
418 418
             );
419 419
         }
420 420
     }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
         Event::on(
429 429
             UrlManager::class,
430 430
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
431
-            function (RegisterUrlRulesEvent $event) {
431
+            function(RegisterUrlRulesEvent $event) {
432 432
                 Craft::debug(
433 433
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
434 434
                     __METHOD__
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
         Event::on(
452 452
             Dashboard::class,
453 453
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
454
-            function (RegisterComponentTypesEvent $event) {
455
-                $event->types[] = RetourWidget::class;
454
+            function(RegisterComponentTypesEvent $event) {
455
+                $event->types[ ] = RetourWidget::class;
456 456
             }
457 457
         );
458 458
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
459 459
         Event::on(
460 460
             UrlManager::class,
461 461
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
462
-            function (RegisterUrlRulesEvent $event) {
462
+            function(RegisterUrlRulesEvent $event) {
463 463
                 Craft::debug(
464 464
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
465 465
                     __METHOD__
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
         Event::on(
476 476
             UserPermissions::class,
477 477
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
478
-            function (RegisterUserPermissionsEvent $event) {
478
+            function(RegisterUserPermissionsEvent $event) {
479 479
                 Craft::debug(
480 480
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
481 481
                     __METHOD__
482 482
                 );
483 483
                 // Register our custom permissions
484
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
484
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
485 485
             }
486 486
         );
487 487
     }
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
         Event::on(
498 498
             ErrorHandler::class,
499 499
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
500
-            function (ExceptionEvent $event) {
500
+            function(ExceptionEvent $event) {
501 501
                 Craft::debug(
502 502
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
503 503
                     __METHOD__
@@ -540,16 +540,16 @@  discard block
 block discarded – undo
540 540
     protected function handleElementUriChange(Element $element)
541 541
     {
542 542
         $uris = $this->getAllElementUris($element);
543
-        if (!empty($this->oldElementUris[$element->id])) {
544
-            $oldElementUris = $this->oldElementUris[$element->id];
543
+        if (!empty($this->oldElementUris[ $element->id ])) {
544
+            $oldElementUris = $this->oldElementUris[ $element->id ];
545 545
             foreach ($uris as $siteId => $newUri) {
546
-                if (!empty($oldElementUris[$siteId])) {
547
-                    $oldUri = $oldElementUris[$siteId];
546
+                if (!empty($oldElementUris[ $siteId ])) {
547
+                    $oldUri = $oldElementUris[ $siteId ];
548 548
                     Craft::debug(
549 549
                         Craft::t(
550 550
                             'retour',
551 551
                             'Comparing old: {oldUri} to new: {newUri}',
552
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
552
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
553 553
                         ),
554 554
                         __METHOD__
555 555
                     );
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
      */
600 600
     protected function getAllElementUris(Element $element): array
601 601
     {
602
-        $uris = [];
602
+        $uris = [ ];
603 603
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
604 604
             $sites = Craft::$app->getSites()->getAllSites();
605 605
             foreach ($sites as $site) {
606 606
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
607 607
                 if ($uri !== null) {
608
-                    $uris[$site->id] = $uri;
608
+                    $uris[ $site->id ] = $uri;
609 609
                 }
610 610
             }
611 611
         }
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
             Craft::t(
615 615
                 'retour',
616 616
                 'Getting Element URIs: {uris}',
617
-                ['uris' => print_r($uris, true)]
617
+                [ 'uris' => print_r($uris, true) ]
618 618
             ),
619 619
             __METHOD__
620 620
         );
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
             [
672 672
                 'key' => 'retour-redirect-caches',
673 673
                 'label' => Craft::t('retour', 'Retour redirect caches'),
674
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
674
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
675 675
             ],
676 676
         ];
677 677
     }
Please login to merge, or discard this patch.
src/gql/types/RetourType.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct(array $config)
33 33
     {
34
-        $config['interfaces'] = [
34
+        $config[ 'interfaces' ] = [
35 35
             RetourInterface::getType(),
36 36
         ];
37 37
 
@@ -45,6 +45,6 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $fieldName = $resolveInfo->fieldName;
47 47
 
48
-        return $source[$fieldName];
48
+        return $source[ $fieldName ];
49 49
     }
50 50
 }
Please login to merge, or discard this patch.
src/gql/resolvers/RetourResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@
 block discarded – undo
40 40
             $siteId = $source->siteId;
41 41
         } else {
42 42
             // Otherwise use the passed in arguments, or defaults
43
-            $uri = $arguments['uri'] ?? '/';
44
-            $siteId = $arguments['siteId'] ?? null;
43
+            $uri = $arguments[ 'uri' ] ?? '/';
44
+            $siteId = $arguments[ 'siteId' ] ?? null;
45 45
         }
46 46
         $uri = trim($uri === '/' ? '__home__' : $uri);
47 47
 
Please login to merge, or discard this patch.
src/gql/interfaces/RetourInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@
 block discarded – undo
48 48
 
49 49
         $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([
50 50
             'name' => static::getName(),
51
-            'fields' => self::class.'::getFieldDefinitions',
51
+            'fields' => self::class . '::getFieldDefinitions',
52 52
             'description' => 'This is the interface implemented by Retour.',
53
-            'resolveType' => function (array $value) {
53
+            'resolveType' => function(array $value) {
54 54
                 return GqlEntityRegistry::getEntity(RetourGenerator::getName());
55 55
             },
56 56
         ]));
Please login to merge, or discard this patch.
src/gql/types/generators/RetourGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,24 +34,24 @@
 block discarded – undo
34 34
      */
35 35
     public static function generateTypes($context = null): array
36 36
     {
37
-        $gqlTypes = [];
37
+        $gqlTypes = [ ];
38 38
         $retourFields = RetourInterface::getFieldDefinitions();
39 39
         $retourArgs = RetourArguments::getArguments();
40 40
         $typeName = self::getName();
41 41
         $retourType = GqlEntityRegistry::getEntity($typeName)
42 42
             ?: GqlEntityRegistry::createEntity($typeName, new RetourType([
43 43
                 'name' => $typeName,
44
-                'args' => function () use ($retourArgs) {
44
+                'args' => function() use ($retourArgs) {
45 45
                     return $retourArgs;
46 46
                 },
47
-                'fields' => function () use ($retourFields) {
47
+                'fields' => function() use ($retourFields) {
48 48
                     return $retourFields;
49 49
                 },
50 50
                 'description' => 'This entity has all the Retour fields',
51 51
             ]));
52 52
 
53
-        $gqlTypes[$typeName] = $retourType;
54
-        TypeLoader::registerType($typeName, function () use ($retourType) {
53
+        $gqlTypes[ $typeName ] = $retourType;
54
+        TypeLoader::registerType($typeName, function() use ($retourType) {
55 55
             return $retourType;
56 56
         });
57 57
 
Please login to merge, or discard this patch.
src/controllers/StatisticsController.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     // Protected Properties
41 41
     // =========================================================================
42 42
 
43
-    protected $allowAnonymous = [];
43
+    protected $allowAnonymous = [ ];
44 44
 
45 45
     // Public Methods
46 46
     // =========================================================================
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response
58 58
     {
59
-        $variables = [];
59
+        $variables = [ ];
60 60
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
61 61
         // Trim the statistics
62 62
         Retour::$plugin->statistics->trimStatistics();
@@ -71,34 +71,34 @@  discard block
 block discarded – undo
71 71
         } catch (InvalidConfigException $e) {
72 72
             Craft::error($e->getMessage(), __METHOD__);
73 73
         }
74
-        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
74
+        $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(
75 75
             '@nystudio107/retour/assetbundles/retour/dist',
76 76
             true
77 77
         );
78 78
         // Enabled sites
79 79
         MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
80
-        $variables['controllerHandle'] = 'dashboard';
80
+        $variables[ 'controllerHandle' ] = 'dashboard';
81 81
 
82 82
         // Basic variables
83
-        $variables['fullPageForm'] = false;
84
-        $variables['docsUrl'] = self::DOCUMENTATION_URL;
85
-        $variables['pluginName'] = $pluginName;
86
-        $variables['title'] = $templateTitle;
87
-        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
88
-        $variables['crumbs'] = [
83
+        $variables[ 'fullPageForm' ] = false;
84
+        $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;
85
+        $variables[ 'pluginName' ] = $pluginName;
86
+        $variables[ 'title' ] = $templateTitle;
87
+        $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';
88
+        $variables[ 'crumbs' ] = [
89 89
             [
90 90
                 'label' => $pluginName,
91 91
                 'url' => UrlHelper::cpUrl('retour'),
92 92
             ],
93 93
             [
94 94
                 'label' => $templateTitle,
95
-                'url' => UrlHelper::cpUrl('retour/dashboard'.$siteHandleUri),
95
+                'url' => UrlHelper::cpUrl('retour/dashboard' . $siteHandleUri),
96 96
             ],
97 97
         ];
98
-        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
99
-        $variables['selectedSubnavItem'] = 'dashboard';
100
-        $variables['showWelcome'] = $showWelcome;
101
-        $variables['settings'] = Retour::$settings;
98
+        $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}";
99
+        $variables[ 'selectedSubnavItem' ] = 'dashboard';
100
+        $variables[ 'showWelcome' ] = $showWelcome;
101
+        $variables[ 'settings' ] = Retour::$settings;
102 102
 
103 103
         // Render the template
104 104
         return $this->renderTemplate('retour/dashboard/index', $variables);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             Craft::t(
117 117
                 'retour',
118 118
                 'Retour statistics cleared: {error}',
119
-                ['error' => $error]
119
+                [ 'error' => $error ]
120 120
             ),
121 121
             __METHOD__
122 122
         );
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             Craft::t(
150 150
                 'retour',
151 151
                 'Retour statistics deleted: {error}',
152
-                ['error' => $stickyError]
152
+                [ 'error' => $stickyError ]
153 153
             ),
154 154
             __METHOD__
155 155
         );
Please login to merge, or discard this patch.
src/services/Redirects.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                 Craft::t(
169 169
                     'retour',
170 170
                     '404 full URL: {fullUrl}, 404 path only: {pathOnly}',
171
-                    ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly]
171
+                    [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ]
172 172
                 ),
173 173
                 __METHOD__
174 174
             );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $response = Craft::$app->getResponse();
203 203
         if ($redirect !== null) {
204 204
             // Figure out what type of source matching was done
205
-            $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
205
+            $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly';
206 206
             switch ($redirectSrcMatch) {
207 207
                 case 'pathonly':
208 208
                     $url = $pathOnly;
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
                     $url = $pathOnly;
215 215
                     break;
216 216
             }
217
-            $dest = $redirect['redirectDestUrl'];
217
+            $dest = $redirect[ 'redirectDestUrl' ];
218 218
             // If this isn't a full URL, make it one based on the appropriate site
219 219
             if (!UrlHelper::isFullUrl($dest)) {
220 220
                 try {
221
-                    $dest = UrlHelper::siteUrl($dest, null, null, $redirect['siteId'] ?? null);
221
+                    $dest = UrlHelper::siteUrl($dest, null, null, $redirect[ 'siteId' ] ?? null);
222 222
                 } catch (\yii\base\Exception $e) {
223 223
                 }
224 224
             }
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
                     $dest .= '?' . $request->getQueryStringWithoutPath();
229 229
                 }
230 230
             }
231
-            $status = $redirect['redirectHttpCode'];
231
+            $status = $redirect[ 'redirectHttpCode' ];
232 232
             Craft::info(
233 233
                 Craft::t(
234 234
                     'retour',
235 235
                     'Redirecting {url} to {dest} with status {status}',
236
-                    ['url' => $url, 'dest' => $dest, 'status' => $status]
236
+                    [ 'url' => $url, 'dest' => $dest, 'status' => $status ]
237 237
                 ),
238 238
                 __METHOD__
239 239
             );
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
     public function getRedirectFromCache($url, int $siteId = 0)
316 316
     {
317 317
         $cache = Craft::$app->getCache();
318
-        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
318
+        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
319 319
         $redirect = $cache->get($cacheKey);
320 320
         Craft::info(
321 321
             Craft::t(
322 322
                 'retour',
323 323
                 'Cached redirect hit for {url}',
324
-                ['url' => $url]
324
+                [ 'url' => $url ]
325 325
             ),
326 326
             __METHOD__
327 327
         );
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
         } catch (SiteNotFoundException $e) {
344 344
             $siteId = 1;
345 345
         }
346
-        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
346
+        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
347 347
         // Create the dependency tags
348 348
         $dependency = new TagDependency([
349 349
             'tags' => [
350 350
                 $this::GLOBAL_REDIRECTS_CACHE_TAG,
351
-                $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,
351
+                $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,
352 352
             ],
353 353
         ]);
354 354
         $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             Craft::t(
357 357
                 'retour',
358 358
                 'Cached redirect saved for {url}',
359
-                ['url' => $url]
359
+                [ 'url' => $url ]
360 360
             ),
361 361
             __METHOD__
362 362
         );
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
         // Iterate through the redirects
387 387
         foreach ($redirects as $redirect) {
388 388
             // Figure out what type of source matching to do
389
-            $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
390
-            $redirectEnabled = (bool)$redirect['enabled'];
389
+            $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly';
390
+            $redirectEnabled = (bool) $redirect[ 'enabled' ];
391 391
             if ($redirectEnabled === true) {
392 392
                 switch ($redirectSrcMatch) {
393 393
                     case 'pathonly':
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
                         $url = $pathOnly;
401 401
                         break;
402 402
                 }
403
-                $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
403
+                $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound';
404 404
                 switch ($redirectMatchType) {
405 405
                     // Do a straight up match
406 406
                     case 'exactmatch':
407
-                        if (strcasecmp($redirect['redirectSrcUrlParsed'], $url) === 0) {
407
+                        if (strcasecmp($redirect[ 'redirectSrcUrlParsed' ], $url) === 0) {
408 408
                             $this->incrementRedirectHitCount($redirect);
409 409
                             $this->saveRedirectToCache($url, $redirect);
410 410
 
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
 
415 415
                     // Do a regex match
416 416
                     case 'regexmatch':
417
-                        $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';
417
+                        $matchRegEx = '`' . $redirect[ 'redirectSrcUrlParsed' ] . '`i';
418 418
                         try {
419 419
                             if (preg_match($matchRegEx, $url) === 1) {
420 420
                                 $this->incrementRedirectHitCount($redirect);
421 421
                                 // If we're not associated with an EntryID, handle capture group replacement
422
-                                if ((int)$redirect['associatedElementId'] === 0) {
423
-                                    $redirect['redirectDestUrl'] = preg_replace(
422
+                                if ((int) $redirect[ 'associatedElementId' ] === 0) {
423
+                                    $redirect[ 'redirectDestUrl' ] = preg_replace(
424 424
                                         $matchRegEx,
425
-                                        $redirect['redirectDestUrl'],
425
+                                        $redirect[ 'redirectDestUrl' ],
426 426
                                         $url
427 427
                                     );
428 428
                                 }
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                             }
433 433
                         } catch (\Exception $e) {
434 434
                             // That's fine
435
-                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__);
435
+                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__);
436 436
                         }
437 437
 
438 438
                         break;
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
                                     'redirect' => &$redirect,
447 447
                                 ],
448 448
                             ];
449
-                            $result = \call_user_func_array([$plugin, 'retourMatch'], $args);
449
+                            $result = \call_user_func_array([ $plugin, 'retourMatch' ], $args);
450 450
                             if ($result) {
451 451
                                 $this->incrementRedirectHitCount($redirect);
452 452
                                 $this->saveRedirectToCache($url, $redirect);
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             Craft::t(
474 474
                 'retour',
475 475
                 'Not handled-> full URL: {fullUrl}, path only: {pathOnly}',
476
-                ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly]
476
+                [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ]
477 477
             ),
478 478
             __METHOD__
479 479
         );
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) {
519 519
             /** @var Plugin $plugin */
520 520
             if (method_exists($plugin, 'retourMatch')) {
521
-                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match');
521
+                $result[ $plugin->getHandle() ] = $plugin->name . Craft::t('retour', ' Match');
522 522
             }
523 523
         }
524 524
 
@@ -539,12 +539,12 @@  discard block
 block discarded – undo
539 539
         }
540 540
         // Query the db table
541 541
         $query = (new Query())
542
-            ->from(['{{%retour_static_redirects}}'])
542
+            ->from([ '{{%retour_static_redirects}}' ])
543 543
             ->orderBy('redirectMatchType ASC, redirectSrcMatch ASC, hitCount DESC');
544 544
         if ($siteId) {
545 545
             $query
546
-                ->where(['siteId' => $siteId])
547
-                ->orWhere(['siteId' => null]);
546
+                ->where([ 'siteId' => $siteId ])
547
+                ->orWhere([ 'siteId' => null ]);
548 548
         }
549 549
         if ($limit) {
550 550
             $query->limit($limit);
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
     {
568 568
         // Query the db table
569 569
         $redirect = (new Query())
570
-            ->from(['{{%retour_static_redirects}}'])
571
-            ->where(['id' => $id])
570
+            ->from([ '{{%retour_static_redirects}}' ])
571
+            ->where([ 'id' => $id ])
572 572
             ->one();
573 573
 
574 574
         return $redirect;
@@ -586,16 +586,16 @@  discard block
 block discarded – undo
586 586
     {
587 587
         // Query the db table
588 588
         $query = (new Query())
589
-            ->from(['{{%retour_static_redirects}}'])
590
-            ->where(['redirectSrcUrl' => $redirectSrcUrl])
589
+            ->from([ '{{%retour_static_redirects}}' ])
590
+            ->where([ 'redirectSrcUrl' => $redirectSrcUrl ])
591 591
             ;
592 592
         if ($siteId) {
593 593
             $query
594
-                ->andWhere(['or', [
594
+                ->andWhere([ 'or', [
595 595
                     'siteId' => $siteId,
596 596
                 ], [
597 597
                     'siteId' => null,
598
-                ]]);
598
+                ] ]);
599 599
         }
600 600
         $redirect = $query->one();
601 601
 
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
     {
638 638
         if ($redirectConfig !== null) {
639 639
             $db = Craft::$app->getDb();
640
-            $redirectConfig['hitCount']++;
641
-            $redirectConfig['hitLastTime'] = Db::prepareDateForDb(new \DateTime());
640
+            $redirectConfig[ 'hitCount' ]++;
641
+            $redirectConfig[ 'hitLastTime' ] = Db::prepareDateForDb(new \DateTime());
642 642
             Craft::debug(
643 643
                 Craft::t(
644 644
                     'retour',
645 645
                     'Incrementing statistics for: {redirect}',
646
-                    ['redirect' => print_r($redirectConfig, true)]
646
+                    [ 'redirect' => print_r($redirectConfig, true) ]
647 647
                 ),
648 648
                 __METHOD__
649 649
             );
@@ -652,14 +652,14 @@  discard block
 block discarded – undo
652 652
                 $rowsAffected = $db->createCommand()->update(
653 653
                     '{{%retour_static_redirects}}',
654 654
                     [
655
-                        'hitCount' => $redirectConfig['hitCount'],
656
-                        'hitLastTime' => $redirectConfig['hitLastTime'],
655
+                        'hitCount' => $redirectConfig[ 'hitCount' ],
656
+                        'hitLastTime' => $redirectConfig[ 'hitLastTime' ],
657 657
                     ],
658 658
                     [
659
-                        'id' => $redirectConfig['id'],
659
+                        'id' => $redirectConfig[ 'id' ],
660 660
                     ]
661 661
                 )->execute();
662
-                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__);
662
+                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__);
663 663
             } catch (\Exception $e) {
664 664
                 Craft::error($e->getMessage(), __METHOD__);
665 665
             }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                 Craft::t(
679 679
                     'retour',
680 680
                     'Error validating redirect {id}: {errors}',
681
-                    ['id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true)]
681
+                    [ 'id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true) ]
682 682
                 ),
683 683
                 __METHOD__
684 684
             );
@@ -688,32 +688,32 @@  discard block
 block discarded – undo
688 688
         // Get the validated model attributes and save them to the db
689 689
         $redirectConfig = $redirect->getAttributes();
690 690
         // 0 for a siteId needs to be converted to null
691
-        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) {
692
-            $redirectConfig['siteId'] = null;
691
+        if (empty($redirectConfig[ 'siteId' ]) || (int) $redirectConfig[ 'siteId' ] === 0) {
692
+            $redirectConfig[ 'siteId' ] = null;
693 693
         }
694 694
         // Throw an event to before saving the redirect
695 695
         $db = Craft::$app->getDb();
696 696
         // See if a redirect exists with this source URL already
697
-        if ((int)$redirectConfig['id'] === 0) {
697
+        if ((int) $redirectConfig[ 'id' ] === 0) {
698 698
             // Query the db table
699 699
             $redirect = (new Query())
700
-                ->from(['{{%retour_static_redirects}}'])
701
-                ->where(['redirectSrcUrlParsed' => $redirectConfig['redirectSrcUrlParsed']])
702
-                ->andWhere(['siteId' => $redirectConfig['siteId']])
700
+                ->from([ '{{%retour_static_redirects}}' ])
701
+                ->where([ 'redirectSrcUrlParsed' => $redirectConfig[ 'redirectSrcUrlParsed' ] ])
702
+                ->andWhere([ 'siteId' => $redirectConfig[ 'siteId' ] ])
703 703
                 ->one();
704 704
             // If it exists, update it rather than having duplicates
705 705
             if (!empty($redirect)) {
706
-                $redirectConfig['id'] = $redirect['id'];
706
+                $redirectConfig[ 'id' ] = $redirect[ 'id' ];
707 707
             }
708 708
         }
709 709
         // Trigger a 'beforeSaveRedirect' event
710
-        $isNew = (int)$redirectConfig['id'] === 0;
710
+        $isNew = (int) $redirectConfig[ 'id' ] === 0;
711 711
         $event = new RedirectEvent([
712 712
             'isNew' => $isNew,
713
-            'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
714
-            'destinationUrl' => $redirectConfig['redirectDestUrl'],
715
-            'matchType' => $redirectConfig['redirectSrcMatch'],
716
-            'redirectType' => $redirectConfig['redirectHttpCode'],
713
+            'legacyUrl' => $redirectConfig[ 'redirectSrcUrlParsed' ],
714
+            'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ],
715
+            'matchType' => $redirectConfig[ 'redirectSrcMatch' ],
716
+            'redirectType' => $redirectConfig[ 'redirectHttpCode' ],
717 717
         ]);
718 718
         $this->trigger(self::EVENT_BEFORE_SAVE_REDIRECT, $event);
719 719
         if (!$event->isValid) {
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
                 Craft::t(
726 726
                     'retour',
727 727
                     'Updating existing redirect: {redirect}',
728
-                    ['redirect' => print_r($redirectConfig, true)]
728
+                    [ 'redirect' => print_r($redirectConfig, true) ]
729 729
                 ),
730 730
                 __METHOD__
731 731
             );
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
                     '{{%retour_static_redirects}}',
736 736
                     $redirectConfig,
737 737
                     [
738
-                        'id' => $redirectConfig['id'],
738
+                        'id' => $redirectConfig[ 'id' ],
739 739
                     ]
740 740
                 )->execute();
741 741
             } catch (Exception $e) {
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
                 Craft::t(
747 747
                     'retour',
748 748
                     'Creating new redirect: {redirect}',
749
-                    ['redirect' => print_r($redirectConfig, true)]
749
+                    [ 'redirect' => print_r($redirectConfig, true) ]
750 750
                 ),
751 751
                 __METHOD__
752 752
             );
753
-            unset($redirectConfig['id']);
753
+            unset($redirectConfig[ 'id' ]);
754 754
             // Create a new record
755 755
             try {
756 756
                 $db->createCommand()->insert(
@@ -763,15 +763,15 @@  discard block
 block discarded – undo
763 763
         }
764 764
         // To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl
765 765
         $testRedirectConfig = $this->getRedirectByRedirectSrcUrl(
766
-            $redirectConfig['redirectDestUrl'],
767
-            $redirectConfig['siteId']
766
+            $redirectConfig[ 'redirectDestUrl' ],
767
+            $redirectConfig[ 'siteId' ]
768 768
         );
769 769
         if ($testRedirectConfig !== null) {
770 770
             Craft::debug(
771 771
                 Craft::t(
772 772
                     'retour',
773 773
                     'Deleting redirect to prevent a loop: {redirect}',
774
-                    ['redirect' => print_r($testRedirectConfig, true)]
774
+                    [ 'redirect' => print_r($testRedirectConfig, true) ]
775 775
                 ),
776 776
                 __METHOD__
777 777
             );
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
             try {
780 780
                 $db->createCommand()->delete(
781 781
                     '{{%retour_static_redirects}}',
782
-                    ['id' => $testRedirectConfig['id']]
782
+                    [ 'id' => $testRedirectConfig[ 'id' ] ]
783 783
                 )->execute();
784 784
             } catch (Exception $e) {
785 785
                 Craft::error($e->getMessage(), __METHOD__);
@@ -812,17 +812,17 @@  discard block
 block discarded – undo
812 812
      */
813 813
     public function excludeUri($uri): bool
814 814
     {
815
-        $uri = '/'.ltrim($uri, '/');
815
+        $uri = '/' . ltrim($uri, '/');
816 816
         if (!empty(Retour::$settings->excludePatterns)) {
817 817
             foreach (Retour::$settings->excludePatterns as $excludePattern) {
818
-                $pattern = '`'.$excludePattern['pattern'].'`i';
818
+                $pattern = '`' . $excludePattern[ 'pattern' ] . '`i';
819 819
                 try {
820 820
                     if (preg_match($pattern, $uri) === 1) {
821 821
                         return true;
822 822
                     }
823 823
                 } catch (\Exception $e) {
824 824
                     // That's fine
825
-                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__);
825
+                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__);
826 826
                 }
827 827
             }
828 828
         }
Please login to merge, or discard this patch.
src/controllers/TablesController.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $handled = 'all'
76 76
     ): Response {
77 77
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
78
-        $data = [];
78
+        $data = [ ];
79 79
         $sortField = 'hitCount';
80 80
         $sortType = 'DESC';
81 81
         // Figure out the sorting type
@@ -87,52 +87,52 @@  discard block
 block discarded – undo
87 87
             }
88 88
         }
89 89
         $sortType = strtoupper($sortType);
90
-        $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];
90
+        $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];
91 91
         // Query the db table
92 92
         $offset = ($page - 1) * $per_page;
93 93
         $query = (new Query())
94
-            ->from(['{{%retour_stats}}'])
94
+            ->from([ '{{%retour_stats}}' ])
95 95
             ->offset($offset)
96 96
             ->limit($per_page)
97
-            ->orderBy([$sortField => $sortType]);
98
-        if ((int)$siteId !== 0) {
99
-            $query->where(['siteId' => $siteId]);
97
+            ->orderBy([ $sortField => $sortType ]);
98
+        if ((int) $siteId !== 0) {
99
+            $query->where([ 'siteId' => $siteId ]);
100 100
         }
101 101
         if ($handled !== 'all') {
102
-            $query->where(['handledByRetour' => self::HANDLED_MAP[$handled]]);
102
+            $query->where([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);
103 103
         }
104 104
         if ($filter !== '') {
105
-            $query->where(['like', 'redirectSrcUrl', $filter]);
106
-            $query->orWhere(['like', 'referrerUrl', $filter]);
105
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
106
+            $query->orWhere([ 'like', 'referrerUrl', $filter ]);
107 107
         }
108 108
         $stats = $query->all();
109 109
         if ($stats) {
110 110
             // Add in the `addLink` field
111 111
             foreach ($stats as &$stat) {
112
-                $stat['addLink'] = '';
113
-                if (!$stat['handledByRetour']) {
114
-                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
115
-                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
112
+                $stat[ 'addLink' ] = '';
113
+                if (!$stat[ 'handledByRetour' ]) {
114
+                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/'));
115
+                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [
116 116
                         'defaultUrl' => $encodedUrl
117 117
                     ]);
118 118
                 }
119 119
             }
120 120
             // Format the data for the API
121
-            $data['data'] = $stats;
121
+            $data[ 'data' ] = $stats;
122 122
             $query = (new Query())
123
-                ->from(['{{%retour_stats}}']);
124
-            if ((int)$siteId !== 0) {
125
-                $query->where(['siteId' => $siteId]);
123
+                ->from([ '{{%retour_stats}}' ]);
124
+            if ((int) $siteId !== 0) {
125
+                $query->where([ 'siteId' => $siteId ]);
126 126
             }
127 127
             if ($handled !== 'all') {
128
-                $query->where(['handledByRetour' => self::HANDLED_MAP[$handled]]);
128
+                $query->where([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);
129 129
             }
130 130
             if ($filter !== '') {
131
-                $query->where(['like', 'redirectSrcUrl', $filter]);
132
-                $query->orWhere(['like', 'referrerUrl', $filter]);
131
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
132
+                $query->orWhere([ 'like', 'referrerUrl', $filter ]);
133 133
             }
134 134
             $count = $query->count();
135
-            $data['links']['pagination'] = [
135
+            $data[ 'links' ][ 'pagination' ] = [
136 136
                 'total' => $count,
137 137
                 'per_page' => $per_page,
138 138
                 'current_page' => $page,
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $siteId = 0
168 168
     ): Response {
169 169
         PermissionHelper::controllerPermissionCheck('retour:redirects');
170
-        $data = [];
170
+        $data = [ ];
171 171
         $sortField = 'hitCount';
172 172
         $sortType = 'DESC';
173 173
         // Figure out the sorting type
@@ -179,56 +179,56 @@  discard block
 block discarded – undo
179 179
             }
180 180
         }
181 181
         $sortType = strtoupper($sortType);
182
-        $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];
182
+        $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];
183 183
         // Query the db table
184 184
         $offset = ($page - 1) * $per_page;
185 185
         $query = (new Query())
186
-            ->from(['{{%retour_static_redirects}}'])
186
+            ->from([ '{{%retour_static_redirects}}' ])
187 187
             ->offset($offset)
188 188
             ->limit($per_page)
189
-            ->orderBy([$sortField => $sortType]);
190
-        if ((int)$siteId !== 0) {
191
-            $query->where(['siteId' => $siteId]);
189
+            ->orderBy([ $sortField => $sortType ]);
190
+        if ((int) $siteId !== 0) {
191
+            $query->where([ 'siteId' => $siteId ]);
192 192
         }
193 193
         if ($filter !== '') {
194
-            $query->where(['like', 'redirectSrcUrl', $filter]);
195
-            $query->orWhere(['like', 'redirectDestUrl', $filter]);
194
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
195
+            $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
196 196
         }
197 197
         $redirects = $query->all();
198 198
         // Add in the `deleteLink` field and clean up the redirects
199 199
         foreach ($redirects as &$redirect) {
200 200
             // Make sure the destination URL is not a regex
201
-            if ($redirect['redirectMatchType'] !== 'exactmatch') {
202
-                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) {
203
-                    $redirect['redirectDestUrl'] = '';
201
+            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') {
202
+                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) {
203
+                    $redirect[ 'redirectDestUrl' ] = '';
204 204
                 }
205 205
             }
206 206
             // Handle extracting the site name
207
-            $redirect['siteName'] = Craft::t('retour', 'All Sites');
208
-            if ($redirect['siteId']) {
207
+            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites');
208
+            if ($redirect[ 'siteId' ]) {
209 209
                 $sites = Craft::$app->getSites();
210
-                $site = $sites->getSiteById($redirect['siteId']);
210
+                $site = $sites->getSiteById($redirect[ 'siteId' ]);
211 211
                 if ($site) {
212
-                    $redirect['siteName'] = $site->name;
212
+                    $redirect[ 'siteName' ] = $site->name;
213 213
                 }
214 214
             }
215 215
 
216
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
216
+            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]);
217 217
         }
218 218
         // Format the data for the API
219 219
         if ($redirects) {
220
-            $data['data'] = $redirects;
220
+            $data[ 'data' ] = $redirects;
221 221
             $query = (new Query())
222
-                ->from(['{{%retour_static_redirects}}']);
223
-            if ((int)$siteId !== 0) {
224
-                $query->where(['siteId' => $siteId]);
222
+                ->from([ '{{%retour_static_redirects}}' ]);
223
+            if ((int) $siteId !== 0) {
224
+                $query->where([ 'siteId' => $siteId ]);
225 225
             }
226 226
             if ($filter !== '') {
227
-                $query->where(['like', 'redirectSrcUrl', $filter]);
228
-                $query->orWhere(['like', 'redirectDestUrl', $filter]);
227
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
228
+                $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
229 229
             }
230 230
             $count = $query->count();
231
-            $data['links']['pagination'] = [
231
+            $data[ 'links' ][ 'pagination' ] = [
232 232
                 'total' => $count,
233 233
                 'per_page' => $per_page,
234 234
                 'current_page' => $page,
Please login to merge, or discard this patch.