Passed
Push — develop ( 33b613...f38256 )
by Andrew
26:50 queued 19:03
created
src/helpers/UrlHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
         /** @noinspection CallableParameterUseCaseInTypeContextInspection */
40 40
         $url = preg_replace('/{.*}/', '', $url);
41 41
         // Remove any linebreaks that may be errantly in the URL
42
-        $url = (string)str_replace([
42
+        $url = (string) str_replace([
43 43
             PHP_EOL,
44 44
                 "\r",
45 45
                 "\n",
Please login to merge, or discard this patch.
src/controllers/ApiController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,6 +57,6 @@
 block discarded – undo
57 57
     {
58 58
         $redirects = Retour::$plugin->redirects->getAllStaticRedirects(null, $siteId);
59 59
 
60
-        return $this->asJson($redirects ?? []);
60
+        return $this->asJson($redirects ?? [ ]);
61 61
     }
62 62
 }
Please login to merge, or discard this patch.
src/models/Settings.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     public function rules()
136 136
     {
137 137
         return [
138
-            ['pluginName', 'string'],
139
-            ['pluginName', 'default', 'value' => 'Retour'],
138
+            [ 'pluginName', 'string' ],
139
+            [ 'pluginName', 'default', 'value' => 'Retour' ],
140 140
             [
141 141
                 [
142 142
                     'createUriChangeRedirects',
@@ -147,22 +147,22 @@  discard block
 block discarded – undo
147 147
                 ],
148 148
                 'boolean',
149 149
             ],
150
-            ['uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly'],
151
-            ['uriChangeRedirectSrcMatch', 'string'],
152
-            ['uriChangeRedirectSrcMatch', 'in', 'range' => [
150
+            [ 'uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly' ],
151
+            [ 'uriChangeRedirectSrcMatch', 'string' ],
152
+            [ 'uriChangeRedirectSrcMatch', 'in', 'range' => [
153 153
                 'pathonly',
154 154
                 'fullurl'
155
-            ]],
156
-            ['staticRedirectDisplayLimit', 'integer', 'min' => 1],
157
-            ['staticRedirectDisplayLimit', 'default', 'value' => 100],
158
-            ['dynamicRedirectDisplayLimit', 'integer', 'min' => 1],
159
-            ['dynamicRedirectDisplayLimit', 'default', 'value' => 100],
160
-            ['statsStoredLimit', 'integer', 'min' => 1],
161
-            ['statsStoredLimit', 'default', 'value' => 1000],
162
-            ['refreshIntervalSecs', 'integer', 'min' => 0],
163
-            ['refreshIntervalSecs', 'default', 'value' => 3],
164
-            ['statsDisplayLimit', 'integer', 'min' => 1],
165
-            ['statsDisplayLimit', 'default', 'value' => 1000],
155
+            ] ],
156
+            [ 'staticRedirectDisplayLimit', 'integer', 'min' => 1 ],
157
+            [ 'staticRedirectDisplayLimit', 'default', 'value' => 100 ],
158
+            [ 'dynamicRedirectDisplayLimit', 'integer', 'min' => 1 ],
159
+            [ 'dynamicRedirectDisplayLimit', 'default', 'value' => 100 ],
160
+            [ 'statsStoredLimit', 'integer', 'min' => 1 ],
161
+            [ 'statsStoredLimit', 'default', 'value' => 1000 ],
162
+            [ 'refreshIntervalSecs', 'integer', 'min' => 0 ],
163
+            [ 'refreshIntervalSecs', 'default', 'value' => 3 ],
164
+            [ 'statsDisplayLimit', 'integer', 'min' => 1 ],
165
+            [ 'statsDisplayLimit', 'default', 'value' => 1000 ],
166 166
             [
167 167
                 [
168 168
                     'excludePatterns',
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function behaviors()
180 180
     {
181
-        $craft31Behaviors = [];
181
+        $craft31Behaviors = [ ];
182 182
         if (Retour::$craft31) {
183 183
             $craft31Behaviors = [
184 184
                 'parser' => [
Please login to merge, or discard this patch.
src/controllers/TablesController.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $handled = 'all'
97 97
     ): Response {
98 98
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
99
-        $data = [];
99
+        $data = [ ];
100 100
         $sortField = 'hitCount';
101 101
         $sortType = 'DESC';
102 102
         // Figure out the sorting type
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             }
109 109
         }
110 110
         $sortType = strtoupper($sortType);
111
-        $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];
111
+        $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];
112 112
         // Validate untrusted data
113 113
         if (!in_array($sortField, self::ALLOWED_STATS_SORT_FIELDS, true)) {
114 114
             throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.'));
@@ -116,35 +116,35 @@  discard block
 block discarded – undo
116 116
         // Query the db table
117 117
         $offset = ($page - 1) * $per_page;
118 118
         $query = (new Query())
119
-            ->from(['{{%retour_stats}}'])
119
+            ->from([ '{{%retour_stats}}' ])
120 120
             ->offset($offset)
121 121
             ->limit($per_page)
122
-            ->orderBy([$sortField => $sortType])
123
-            ->filterWhere(['like', 'redirectSrcUrl', $filter])
124
-            ->orFilterWhere(['like', 'referrerUrl', $filter])
122
+            ->orderBy([ $sortField => $sortType ])
123
+            ->filterWhere([ 'like', 'redirectSrcUrl', $filter ])
124
+            ->orFilterWhere([ 'like', 'referrerUrl', $filter ])
125 125
             ;
126
-        if ((int)$siteId !== 0) {
127
-            $query->andWhere(['siteId' => $siteId]);
126
+        if ((int) $siteId !== 0) {
127
+            $query->andWhere([ 'siteId' => $siteId ]);
128 128
         }
129 129
         if ($handled !== 'all') {
130
-            $query->andWhere(['handledByRetour' => self::HANDLED_MAP[$handled]]);
130
+            $query->andWhere([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);
131 131
         }
132 132
         $stats = $query->all();
133 133
         if ($stats) {
134 134
             // Add in the `addLink` field
135 135
             foreach ($stats as &$stat) {
136
-                $stat['addLink'] = '';
137
-                if (!$stat['handledByRetour']) {
138
-                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
139
-                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
136
+                $stat[ 'addLink' ] = '';
137
+                if (!$stat[ 'handledByRetour' ]) {
138
+                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/'));
139
+                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [
140 140
                         'defaultUrl' => $encodedUrl
141 141
                     ]);
142 142
                 }
143 143
             }
144 144
             // Format the data for the API
145
-            $data['data'] = $stats;
145
+            $data[ 'data' ] = $stats;
146 146
             $count = $query->count();
147
-            $data['links']['pagination'] = [
147
+            $data[ 'links' ][ 'pagination' ] = [
148 148
                 'total' => $count,
149 149
                 'per_page' => $per_page,
150 150
                 'current_page' => $page,
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         $siteId = 0
181 181
     ): Response {
182 182
         PermissionHelper::controllerPermissionCheck('retour:redirects');
183
-        $data = [];
183
+        $data = [ ];
184 184
         $sortField = 'hitCount';
185 185
         $sortType = 'DESC';
186 186
         // Figure out the sorting type
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             }
193 193
         }
194 194
         $sortType = strtoupper($sortType);
195
-        $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];
195
+        $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];
196 196
         // Validate untrusted data
197 197
         if (!in_array($sortField, self::ALLOWED_REDIRECTS_SORT_FIELDS, true)) {
198 198
             throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.'));
@@ -200,42 +200,42 @@  discard block
 block discarded – undo
200 200
         // Query the db table
201 201
         $offset = ($page - 1) * $per_page;
202 202
         $query = (new Query())
203
-            ->from(['{{%retour_static_redirects}}'])
203
+            ->from([ '{{%retour_static_redirects}}' ])
204 204
             ->offset($offset)
205 205
             ->limit($per_page)
206
-            ->orderBy([$sortField => $sortType])
207
-            ->filterWhere(['like', 'redirectSrcUrl', $filter])
208
-            ->orFilterWhere(['like', 'redirectDestUrl', $filter])
206
+            ->orderBy([ $sortField => $sortType ])
207
+            ->filterWhere([ 'like', 'redirectSrcUrl', $filter ])
208
+            ->orFilterWhere([ 'like', 'redirectDestUrl', $filter ])
209 209
            ;
210
-        if ((int)$siteId !== 0) {
211
-            $query->andWhere(['siteId' => $siteId]);
210
+        if ((int) $siteId !== 0) {
211
+            $query->andWhere([ 'siteId' => $siteId ]);
212 212
         }
213 213
         $redirects = $query->all();
214 214
         // Add in the `deleteLink` field and clean up the redirects
215 215
         foreach ($redirects as &$redirect) {
216 216
             // Make sure the destination URL is not a regex
217
-            if ($redirect['redirectMatchType'] !== 'exactmatch') {
218
-                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) {
219
-                    $redirect['redirectDestUrl'] = '';
217
+            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') {
218
+                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) {
219
+                    $redirect[ 'redirectDestUrl' ] = '';
220 220
                 }
221 221
             }
222 222
             // Handle extracting the site name
223
-            $redirect['siteName'] = Craft::t('retour', 'All Sites');
224
-            if ($redirect['siteId']) {
223
+            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites');
224
+            if ($redirect[ 'siteId' ]) {
225 225
                 $sites = Craft::$app->getSites();
226
-                $site = $sites->getSiteById($redirect['siteId']);
226
+                $site = $sites->getSiteById($redirect[ 'siteId' ]);
227 227
                 if ($site) {
228
-                    $redirect['siteName'] = $site->name;
228
+                    $redirect[ 'siteName' ] = $site->name;
229 229
                 }
230 230
             }
231 231
 
232
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
232
+            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]);
233 233
         }
234 234
         // Format the data for the API
235 235
         if ($redirects) {
236
-            $data['data'] = $redirects;
236
+            $data[ 'data' ] = $redirects;
237 237
             $count = $query->count();
238
-            $data['links']['pagination'] = [
238
+            $data[ 'links' ][ 'pagination' ] = [
239 239
                 'total' => $count,
240 240
                 'per_page' => $per_page,
241 241
                 'current_page' => $page,
Please login to merge, or discard this patch.
src/services/Redirects.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 Craft::t(
191 191
                     'retour',
192 192
                     '404 full URL: {fullUrl}, 404 path only: {pathOnly}',
193
-                    ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly]
193
+                    [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ]
194 194
                 ),
195 195
                 __METHOD__
196 196
             );
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         $response = Craft::$app->getResponse();
225 225
         if ($redirect !== null) {
226 226
             // Figure out what type of source matching was done
227
-            $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
227
+            $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly';
228 228
             switch ($redirectSrcMatch) {
229 229
                 case 'pathonly':
230 230
                     $url = $pathOnly;
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
                     $url = $pathOnly;
237 237
                     break;
238 238
             }
239
-            $dest = $redirect['redirectDestUrl'];
239
+            $dest = $redirect[ 'redirectDestUrl' ];
240 240
             // If this isn't a full URL, make it one based on the appropriate site
241 241
             if (!UrlHelper::isFullUrl($dest)) {
242 242
                 try {
243
-                    $siteId = $redirect['siteId'] ?? null;
243
+                    $siteId = $redirect[ 'siteId' ] ?? null;
244 244
                     if ($siteId !== null) {
245
-                        $siteId = (int)$siteId;
245
+                        $siteId = (int) $siteId;
246 246
                     }
247 247
                     $dest = UrlHelper::siteUrl($dest, null, null, $siteId);
248 248
                 } catch (\yii\base\Exception $e) {
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
                     $dest .= '?' . $request->getQueryStringWithoutPath();
255 255
                 }
256 256
             }
257
-            $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
257
+            $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound';
258 258
             // Parse reference tags for exact matches
259 259
             if ($redirectMatchType === 'exactmatch') {
260
-                $dest = Craft::$app->elements->parseRefs($dest, $redirect['siteId'] ?? null);
260
+                $dest = Craft::$app->elements->parseRefs($dest, $redirect[ 'siteId' ] ?? null);
261 261
             }
262
-            $status = $redirect['redirectHttpCode'];
262
+            $status = $redirect[ 'redirectHttpCode' ];
263 263
             Craft::info(
264 264
                 Craft::t(
265 265
                     'retour',
266 266
                     'Redirecting {url} to {dest} with status {status}',
267
-                    ['url' => $url, 'dest' => $dest, 'status' => $status]
267
+                    [ 'url' => $url, 'dest' => $dest, 'status' => $status ]
268 268
                 ),
269 269
                 __METHOD__
270 270
             );
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             // Add any additional headers (existing ones will be replaced)
289 289
             if (!empty(Retour::$settings->additionalHeaders)) {
290 290
                 foreach (Retour::$settings->additionalHeaders as $additionalHeader) {
291
-                    $response->headers->set($additionalHeader['name'], $additionalHeader['value']);
291
+                    $response->headers->set($additionalHeader[ 'name' ], $additionalHeader[ 'value' ]);
292 292
                 }
293 293
             }
294 294
             // Redirect the request away;
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
     public function getRedirectFromCache($url, int $siteId = 0)
360 360
     {
361 361
         $cache = Craft::$app->getCache();
362
-        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
362
+        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
363 363
         $redirect = $cache->get($cacheKey);
364 364
         Craft::info(
365 365
             Craft::t(
366 366
                 'retour',
367 367
                 'Cached redirect hit for {url}',
368
-                ['url' => $url]
368
+                [ 'url' => $url ]
369 369
             ),
370 370
             __METHOD__
371 371
         );
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
         } catch (SiteNotFoundException $e) {
388 388
             $siteId = 1;
389 389
         }
390
-        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
390
+        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
391 391
         // Create the dependency tags
392 392
         $dependency = new TagDependency([
393 393
             'tags' => [
394 394
                 $this::GLOBAL_REDIRECTS_CACHE_TAG,
395
-                $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,
395
+                $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,
396 396
             ],
397 397
         ]);
398 398
         $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             Craft::t(
401 401
                 'retour',
402 402
                 'Cached redirect saved for {url}',
403
-                ['url' => $url]
403
+                [ 'url' => $url ]
404 404
             ),
405 405
             __METHOD__
406 406
         );
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
         // Iterate through the redirects
431 431
         foreach ($redirects as $redirect) {
432 432
             // Figure out what type of source matching to do
433
-            $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
434
-            $redirectEnabled = (bool)$redirect['enabled'];
433
+            $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly';
434
+            $redirectEnabled = (bool) $redirect[ 'enabled' ];
435 435
             if ($redirectEnabled === true) {
436 436
                 switch ($redirectSrcMatch) {
437 437
                     case 'pathonly':
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
                         $url = $pathOnly;
445 445
                         break;
446 446
                 }
447
-                $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
447
+                $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound';
448 448
                 switch ($redirectMatchType) {
449 449
                     // Do a straight up match
450 450
                     case 'exactmatch':
451
-                        if (strcasecmp($redirect['redirectSrcUrlParsed'], $url) === 0) {
451
+                        if (strcasecmp($redirect[ 'redirectSrcUrlParsed' ], $url) === 0) {
452 452
                             $this->incrementRedirectHitCount($redirect);
453 453
                             $this->saveRedirectToCache($url, $redirect);
454 454
 
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
 
472 472
                     // Do a regex match
473 473
                     case 'regexmatch':
474
-                        $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';
474
+                        $matchRegEx = '`' . $redirect[ 'redirectSrcUrlParsed' ] . '`i';
475 475
                         try {
476 476
                             if (preg_match($matchRegEx, $url) === 1) {
477 477
                                 $this->incrementRedirectHitCount($redirect);
478 478
                                 // If we're not associated with an EntryID, handle capture group replacement
479
-                                if ((int)$redirect['associatedElementId'] === 0) {
480
-                                    $redirect['redirectDestUrl'] = preg_replace(
479
+                                if ((int) $redirect[ 'associatedElementId' ] === 0) {
480
+                                    $redirect[ 'redirectDestUrl' ] = preg_replace(
481 481
                                         $matchRegEx,
482
-                                        $redirect['redirectDestUrl'],
482
+                                        $redirect[ 'redirectDestUrl' ],
483 483
                                         $url
484 484
                                     );
485 485
                                 }
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                             }
504 504
                         } catch (\Exception $e) {
505 505
                             // That's fine
506
-                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__);
506
+                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__);
507 507
                         }
508 508
 
509 509
                         break;
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
                                     'redirect' => &$redirect,
518 518
                                 ],
519 519
                             ];
520
-                            $result = \call_user_func_array([$plugin, 'retourMatch'], $args);
520
+                            $result = \call_user_func_array([ $plugin, 'retourMatch' ], $args);
521 521
                             if ($result) {
522 522
                                 $this->incrementRedirectHitCount($redirect);
523 523
                                 $this->saveRedirectToCache($url, $redirect);
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
             Craft::t(
558 558
                 'retour',
559 559
                 'Not handled-> full URL: {fullUrl}, path only: {pathOnly}',
560
-                ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly]
560
+                [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ]
561 561
             ),
562 562
             __METHOD__
563 563
         );
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 
585 585
             if ($url !== null && $redirect !== null) {
586 586
                 // Save the modified redirect to the cache
587
-                $redirect['redirectDestUrl'] = $event->redirectDestUrl;
588
-                $redirect['redirectHttpCode'] = $event->redirectHttpCode;
587
+                $redirect[ 'redirectDestUrl' ] = $event->redirectDestUrl;
588
+                $redirect[ 'redirectHttpCode' ] = $event->redirectHttpCode;
589 589
                 $this->saveRedirectToCache($url, $redirect);
590 590
             }
591 591
         }
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) {
610 610
             /** @var Plugin $plugin */
611 611
             if (method_exists($plugin, 'retourMatch')) {
612
-                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match');
612
+                $result[ $plugin->getHandle() ] = $plugin->name . Craft::t('retour', ' Match');
613 613
             }
614 614
         }
615 615
 
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
         }
631 631
         // Query the db table
632 632
         $query = (new Query())
633
-            ->from(['{{%retour_static_redirects}}'])
633
+            ->from([ '{{%retour_static_redirects}}' ])
634 634
             ->orderBy('redirectMatchType ASC, redirectSrcMatch ASC, hitCount DESC');
635 635
         if ($siteId) {
636 636
             $query
637
-                ->where(['siteId' => $siteId])
638
-                ->orWhere(['siteId' => null]);
637
+                ->where([ 'siteId' => $siteId ])
638
+                ->orWhere([ 'siteId' => null ]);
639 639
         }
640 640
         if ($limit) {
641 641
             $query->limit($limit);
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
     {
659 659
         // Query the db table
660 660
         $redirect = (new Query())
661
-            ->from(['{{%retour_static_redirects}}'])
662
-            ->where(['id' => $id])
661
+            ->from([ '{{%retour_static_redirects}}' ])
662
+            ->where([ 'id' => $id ])
663 663
             ->one();
664 664
 
665 665
         return $redirect;
@@ -677,16 +677,16 @@  discard block
 block discarded – undo
677 677
     {
678 678
         // Query the db table
679 679
         $query = (new Query())
680
-            ->from(['{{%retour_static_redirects}}'])
681
-            ->where(['redirectSrcUrl' => $redirectSrcUrl])
680
+            ->from([ '{{%retour_static_redirects}}' ])
681
+            ->where([ 'redirectSrcUrl' => $redirectSrcUrl ])
682 682
             ;
683 683
         if ($siteId) {
684 684
             $query
685
-                ->andWhere(['or', [
685
+                ->andWhere([ 'or', [
686 686
                     'siteId' => $siteId,
687 687
                 ], [
688 688
                     'siteId' => null,
689
-                ]]);
689
+                ] ]);
690 690
         }
691 691
         $redirect = $query->one();
692 692
 
@@ -728,13 +728,13 @@  discard block
 block discarded – undo
728 728
     {
729 729
         if ($redirectConfig !== null) {
730 730
             $db = Craft::$app->getDb();
731
-            $redirectConfig['hitCount']++;
732
-            $redirectConfig['hitLastTime'] = Db::prepareDateForDb(new \DateTime());
731
+            $redirectConfig[ 'hitCount' ]++;
732
+            $redirectConfig[ 'hitLastTime' ] = Db::prepareDateForDb(new \DateTime());
733 733
             Craft::debug(
734 734
                 Craft::t(
735 735
                     'retour',
736 736
                     'Incrementing statistics for: {redirect}',
737
-                    ['redirect' => print_r($redirectConfig, true)]
737
+                    [ 'redirect' => print_r($redirectConfig, true) ]
738 738
                 ),
739 739
                 __METHOD__
740 740
             );
@@ -743,14 +743,14 @@  discard block
 block discarded – undo
743 743
                 $rowsAffected = $db->createCommand()->update(
744 744
                     '{{%retour_static_redirects}}',
745 745
                     [
746
-                        'hitCount' => $redirectConfig['hitCount'],
747
-                        'hitLastTime' => $redirectConfig['hitLastTime'],
746
+                        'hitCount' => $redirectConfig[ 'hitCount' ],
747
+                        'hitLastTime' => $redirectConfig[ 'hitLastTime' ],
748 748
                     ],
749 749
                     [
750
-                        'id' => $redirectConfig['id'],
750
+                        'id' => $redirectConfig[ 'id' ],
751 751
                     ]
752 752
                 )->execute();
753
-                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__);
753
+                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__);
754 754
             } catch (\Exception $e) {
755 755
                 Craft::error($e->getMessage(), __METHOD__);
756 756
             }
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
     public function saveRedirect(array $redirectConfig)
764 764
     {
765 765
         // Handle URL encoded URLs by decoding them before saving them
766
-        if ($redirectConfig['redirectMatchType'] === 'exactmatch') {
767
-            $redirectConfig['redirectSrcUrl'] = urldecode($redirectConfig['redirectSrcUrl'] ?? '');
768
-            $redirectConfig['redirectSrcUrlParsed'] = urldecode($redirectConfig['redirectSrcUrlParsed'] ?? '');
766
+        if ($redirectConfig[ 'redirectMatchType' ] === 'exactmatch') {
767
+            $redirectConfig[ 'redirectSrcUrl' ] = urldecode($redirectConfig[ 'redirectSrcUrl' ] ?? '');
768
+            $redirectConfig[ 'redirectSrcUrlParsed' ] = urldecode($redirectConfig[ 'redirectSrcUrlParsed' ] ?? '');
769 769
         }
770 770
         // Validate the model before saving it to the db
771 771
         $redirect = new StaticRedirectsModel($redirectConfig);
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
                 Craft::t(
775 775
                     'retour',
776 776
                     'Error validating redirect {id}: {errors}',
777
-                    ['id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true)]
777
+                    [ 'id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true) ]
778 778
                 ),
779 779
                 __METHOD__
780 780
             );
@@ -784,32 +784,32 @@  discard block
 block discarded – undo
784 784
         // Get the validated model attributes and save them to the db
785 785
         $redirectConfig = $redirect->getAttributes();
786 786
         // 0 for a siteId needs to be converted to null
787
-        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) {
788
-            $redirectConfig['siteId'] = null;
787
+        if (empty($redirectConfig[ 'siteId' ]) || (int) $redirectConfig[ 'siteId' ] === 0) {
788
+            $redirectConfig[ 'siteId' ] = null;
789 789
         }
790 790
         // Throw an event to before saving the redirect
791 791
         $db = Craft::$app->getDb();
792 792
         // See if a redirect exists with this source URL already
793
-        if ((int)$redirectConfig['id'] === 0) {
793
+        if ((int) $redirectConfig[ 'id' ] === 0) {
794 794
             // Query the db table
795 795
             $redirect = (new Query())
796
-                ->from(['{{%retour_static_redirects}}'])
797
-                ->where(['redirectSrcUrlParsed' => $redirectConfig['redirectSrcUrlParsed']])
798
-                ->andWhere(['siteId' => $redirectConfig['siteId']])
796
+                ->from([ '{{%retour_static_redirects}}' ])
797
+                ->where([ 'redirectSrcUrlParsed' => $redirectConfig[ 'redirectSrcUrlParsed' ] ])
798
+                ->andWhere([ 'siteId' => $redirectConfig[ 'siteId' ] ])
799 799
                 ->one();
800 800
             // If it exists, update it rather than having duplicates
801 801
             if (!empty($redirect)) {
802
-                $redirectConfig['id'] = $redirect['id'];
802
+                $redirectConfig[ 'id' ] = $redirect[ 'id' ];
803 803
             }
804 804
         }
805 805
         // Trigger a 'beforeSaveRedirect' event
806
-        $isNew = (int)$redirectConfig['id'] === 0;
806
+        $isNew = (int) $redirectConfig[ 'id' ] === 0;
807 807
         $event = new RedirectEvent([
808 808
             'isNew' => $isNew,
809
-            'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
810
-            'destinationUrl' => $redirectConfig['redirectDestUrl'],
811
-            'matchType' => $redirectConfig['redirectSrcMatch'],
812
-            'redirectType' => $redirectConfig['redirectHttpCode'],
809
+            'legacyUrl' => $redirectConfig[ 'redirectSrcUrlParsed' ],
810
+            'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ],
811
+            'matchType' => $redirectConfig[ 'redirectSrcMatch' ],
812
+            'redirectType' => $redirectConfig[ 'redirectHttpCode' ],
813 813
         ]);
814 814
         $this->trigger(self::EVENT_BEFORE_SAVE_REDIRECT, $event);
815 815
         if (!$event->isValid) {
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                 Craft::t(
822 822
                     'retour',
823 823
                     'Updating existing redirect: {redirect}',
824
-                    ['redirect' => print_r($redirectConfig, true)]
824
+                    [ 'redirect' => print_r($redirectConfig, true) ]
825 825
                 ),
826 826
                 __METHOD__
827 827
             );
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
                     '{{%retour_static_redirects}}',
832 832
                     $redirectConfig,
833 833
                     [
834
-                        'id' => $redirectConfig['id'],
834
+                        'id' => $redirectConfig[ 'id' ],
835 835
                     ]
836 836
                 )->execute();
837 837
             } catch (Exception $e) {
@@ -842,11 +842,11 @@  discard block
 block discarded – undo
842 842
                 Craft::t(
843 843
                     'retour',
844 844
                     'Creating new redirect: {redirect}',
845
-                    ['redirect' => print_r($redirectConfig, true)]
845
+                    [ 'redirect' => print_r($redirectConfig, true) ]
846 846
                 ),
847 847
                 __METHOD__
848 848
             );
849
-            unset($redirectConfig['id']);
849
+            unset($redirectConfig[ 'id' ]);
850 850
             // Create a new record
851 851
             try {
852 852
                 $db->createCommand()->insert(
@@ -859,15 +859,15 @@  discard block
 block discarded – undo
859 859
         }
860 860
         // To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl
861 861
         $testRedirectConfig = $this->getRedirectByRedirectSrcUrl(
862
-            $redirectConfig['redirectDestUrl'],
863
-            $redirectConfig['siteId']
862
+            $redirectConfig[ 'redirectDestUrl' ],
863
+            $redirectConfig[ 'siteId' ]
864 864
         );
865 865
         if ($testRedirectConfig !== null) {
866 866
             Craft::debug(
867 867
                 Craft::t(
868 868
                     'retour',
869 869
                     'Deleting redirect to prevent a loop: {redirect}',
870
-                    ['redirect' => print_r($testRedirectConfig, true)]
870
+                    [ 'redirect' => print_r($testRedirectConfig, true) ]
871 871
                 ),
872 872
                 __METHOD__
873 873
             );
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
             try {
876 876
                 $db->createCommand()->delete(
877 877
                     '{{%retour_static_redirects}}',
878
-                    ['id' => $testRedirectConfig['id']]
878
+                    [ 'id' => $testRedirectConfig[ 'id' ] ]
879 879
                 )->execute();
880 880
             } catch (Exception $e) {
881 881
                 Craft::error($e->getMessage(), __METHOD__);
@@ -918,17 +918,17 @@  discard block
 block discarded – undo
918 918
      */
919 919
     public function excludeUri($uri): bool
920 920
     {
921
-        $uri = '/'.ltrim($uri, '/');
921
+        $uri = '/' . ltrim($uri, '/');
922 922
         if (!empty(Retour::$settings->excludePatterns)) {
923 923
             foreach (Retour::$settings->excludePatterns as $excludePattern) {
924
-                $pattern = '`'.$excludePattern['pattern'].'`i';
924
+                $pattern = '`' . $excludePattern[ 'pattern' ] . '`i';
925 925
                 try {
926 926
                     if (preg_match($pattern, $uri) === 1) {
927 927
                         return true;
928 928
                     }
929 929
                 } catch (\Exception $e) {
930 930
                     // That's fine
931
-                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__);
931
+                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__);
932 932
                 }
933 933
             }
934 934
         }
Please login to merge, or discard this patch.
src/controllers/RedirectsController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     // Protected Properties
42 42
     // =========================================================================
43 43
 
44
-    protected $allowAnonymous = [];
44
+    protected $allowAnonymous = [ ];
45 45
 
46 46
     // Public Methods
47 47
     // =========================================================================
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function actionRedirects(string $siteHandle = null): Response
59 59
     {
60
-        $variables = [];
60
+        $variables = [ ];
61 61
         PermissionHelper::controllerPermissionCheck('retour:redirects');
62 62
         // Get the site to edit
63 63
         $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
@@ -70,32 +70,32 @@  discard block
 block discarded – undo
70 70
         } catch (InvalidConfigException $e) {
71 71
             Craft::error($e->getMessage(), __METHOD__);
72 72
         }
73
-        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
73
+        $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(
74 74
             '@nystudio107/retour/assetbundles/retour/dist',
75 75
             true
76 76
         );
77 77
         // Enabled sites
78 78
         MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
79
-        $variables['controllerHandle'] = 'redirects';
79
+        $variables[ 'controllerHandle' ] = 'redirects';
80 80
 
81 81
         // Basic variables
82
-        $variables['fullPageForm'] = false;
83
-        $variables['docsUrl'] = self::DOCUMENTATION_URL;
84
-        $variables['pluginName'] = $pluginName;
85
-        $variables['title'] = $templateTitle;
86
-        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
87
-        $variables['crumbs'] = [
82
+        $variables[ 'fullPageForm' ] = false;
83
+        $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;
84
+        $variables[ 'pluginName' ] = $pluginName;
85
+        $variables[ 'title' ] = $templateTitle;
86
+        $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';
87
+        $variables[ 'crumbs' ] = [
88 88
             [
89 89
                 'label' => $pluginName,
90 90
                 'url' => UrlHelper::cpUrl('retour'),
91 91
             ],
92 92
             [
93 93
                 'label' => $templateTitle,
94
-                'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri),
94
+                'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri),
95 95
             ],
96 96
         ];
97
-        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
98
-        $variables['selectedSubnavItem'] = 'redirects';
97
+        $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}";
98
+        $variables[ 'selectedSubnavItem' ] = 'redirects';
99 99
 
100 100
         // Render the template
101 101
         return $this->renderTemplate('retour/redirects/index', $variables);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         int $siteId = 0,
120 120
         StaticRedirectsModel $redirect = null
121 121
     ): Response {
122
-        $variables = [];
122
+        $variables = [ ];
123 123
         PermissionHelper::controllerPermissionCheck('retour:redirects');
124 124
 
125 125
         // Load in the redirect
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
         if ($redirect === null) {
134 134
             $redirectConfig = Retour::$plugin->redirects->getRedirectById($redirectId);
135 135
             if ($redirectConfig === null) {
136
-                $redirectConfig = [];
136
+                $redirectConfig = [ ];
137 137
                 Craft::error(
138 138
                     Craft::t(
139 139
                         'retour',
140 140
                         "Couldn't load redirect id {id}",
141
-                        ['id' => $redirectId]
141
+                        [ 'id' => $redirectId ]
142 142
                     ),
143 143
                     __METHOD__
144 144
                 );
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
         if ($redirect->siteId) {
152 152
             $site = $sites->getSiteById($redirect->siteId);
153 153
             if ($site) {
154
-                MultiSiteHelper::requirePermission('editSite:'.$site->uid);
154
+                MultiSiteHelper::requirePermission('editSite:' . $site->uid);
155 155
             }
156 156
         }
157 157
         if ($siteId) {
158 158
             $site = $sites->getSiteById($siteId);
159 159
             if ($site) {
160
-                MultiSiteHelper::requirePermission('editSite:'.$site->uid);
160
+                MultiSiteHelper::requirePermission('editSite:' . $site->uid);
161 161
             }
162 162
         }
163 163
         $pluginName = Retour::$settings->pluginName;
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
         } catch (InvalidConfigException $e) {
170 170
             Craft::error($e->getMessage(), __METHOD__);
171 171
         }
172
-        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
172
+        $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(
173 173
             '@nystudio107/retour/assetbundles/retour/dist',
174 174
             true
175 175
         );
176 176
         // Sites menu
177 177
         MultiSiteHelper::setSitesMenuVariables($variables);
178
-        $variables['controllerHandle'] = 'redirects';
178
+        $variables[ 'controllerHandle' ] = 'redirects';
179 179
 
180 180
         // Basic variables
181
-        $variables['fullPageForm'] = true;
182
-        $variables['docsUrl'] = self::DOCUMENTATION_URL;
183
-        $variables['pluginName'] = $pluginName;
184
-        $variables['title'] = $templateTitle;
185
-        $variables['crumbs'] = [
181
+        $variables[ 'fullPageForm' ] = true;
182
+        $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;
183
+        $variables[ 'pluginName' ] = $pluginName;
184
+        $variables[ 'title' ] = $templateTitle;
185
+        $variables[ 'crumbs' ] = [
186 186
             [
187 187
                 'label' => $pluginName,
188 188
                 'url' => UrlHelper::cpUrl('retour'),
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
             ],
194 194
             [
195 195
                 'label' => $templateTitle,
196
-                'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId),
196
+                'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId),
197 197
             ],
198 198
         ];
199
-        $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}";
200
-        $variables['selectedSubnavItem'] = 'redirects';
201
-        $variables['redirect'] = $redirect;
199
+        $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}";
200
+        $variables[ 'selectedSubnavItem' ] = 'redirects';
201
+        $variables[ 'redirect' ] = $redirect;
202 202
 
203 203
         // Render the template
204 204
         return $this->renderTemplate('retour/redirects/_edit', $variables);
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
         if ($redirectConfig === null) {
252 252
             throw new NotFoundHttpException('Redirect not found');
253 253
         }
254
-        $redirectConfig['id'] = (int)$redirectConfig['id'];
254
+        $redirectConfig[ 'id' ] = (int) $redirectConfig[ 'id' ];
255 255
         // Handle enforcing trailing slashes
256 256
         $generalConfig = Craft::$app->getConfig()->getGeneral();
257
-        if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') {
258
-            $destUrl = $redirectConfig['redirectDestUrl'] ?? '';
259
-            $redirectConfig['redirectDestUrl'] = $this->addSlashToSiteUrls($destUrl);
257
+        if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig[ 'redirectMatchType' ] === 'exactmatch') {
258
+            $destUrl = $redirectConfig[ 'redirectDestUrl' ] ?? '';
259
+            $redirectConfig[ 'redirectDestUrl' ] = $this->addSlashToSiteUrls($destUrl);
260 260
         }
261 261
         // Handle URL encoded URLs by decoding them before saving them
262
-        if ($redirectConfig['redirectMatchType'] === 'exactmatch') {
263
-            $redirectConfig['redirectSrcUrl'] = urldecode($redirectConfig['redirectSrcUrl'] ?? '');
264
-            $redirectConfig['redirectSrcUrlParsed'] = urldecode($redirectConfig['redirectSrcUrlParsed'] ?? '');
262
+        if ($redirectConfig[ 'redirectMatchType' ] === 'exactmatch') {
263
+            $redirectConfig[ 'redirectSrcUrl' ] = urldecode($redirectConfig[ 'redirectSrcUrl' ] ?? '');
264
+            $redirectConfig[ 'redirectSrcUrlParsed' ] = urldecode($redirectConfig[ 'redirectSrcUrlParsed' ] ?? '');
265 265
         }
266 266
         $redirect = new StaticRedirectsModel($redirectConfig);
267 267
         // Make sure the redirect validates
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
         Retour::$plugin->redirects->saveRedirect($redirectConfig);
280 280
         // Handle the case where the redirect wasn't saved because it'd create a redirect loop
281 281
         $testRedirectConfig = Retour::$plugin->redirects->getRedirectByRedirectSrcUrl(
282
-            $redirectConfig['redirectSrcUrl'],
283
-            $redirectConfig['siteId']
282
+            $redirectConfig[ 'redirectSrcUrl' ],
283
+            $redirectConfig[ 'siteId' ]
284 284
         );
285 285
         if ($testRedirectConfig === null) {
286 286
             Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings because it'd create a redirect loop."));
Please login to merge, or discard this patch.
src/migrations/m210603_221000_add_gql_schema_components.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
         $schemaVersion = $projectConfig->get('plugins.retour.schemaVersion', true);
21 21
 
22 22
         if (version_compare($schemaVersion, '3.0.10', '<')) {
23
-            foreach ($projectConfig->get('graphql.schemas') ?? [] as $schemaUid => $schemaComponents) {
24
-                if (isset($schemaComponents['scope'])) {
25
-                    $scope = $schemaComponents['scope'];
26
-                    $scope[] = 'retour.all:read';
23
+            foreach ($projectConfig->get('graphql.schemas') ?? [ ] as $schemaUid => $schemaComponents) {
24
+                if (isset($schemaComponents[ 'scope' ])) {
25
+                    $scope = $schemaComponents[ 'scope' ];
26
+                    $scope[ ] = 'retour.all:read';
27 27
 
28 28
                     $projectConfig->set("graphql.schemas.$schemaUid.scope", $scope);
29 29
                 }
Please login to merge, or discard this patch.
src/helpers/Gql.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,6 +17,6 @@
 block discarded – undo
17 17
     {
18 18
         $allowedEntities = self::extractAllowedEntitiesFromSchema();
19 19
 
20
-        return isset($allowedEntities['retour']);
20
+        return isset($allowedEntities[ 'retour' ]);
21 21
     }
22 22
 }
Please login to merge, or discard this patch.
src/Retour.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @inheritdoc
122 122
      */
123
-    public function __construct($id, $parent = null, array $config = [])
123
+    public function __construct($id, $parent = null, array $config = [ ])
124 124
     {
125
-        $config['components'] = [
125
+        $config[ 'components' ] = [
126 126
             'redirects' => Redirects::class,
127 127
             'statistics' => Statistics::class,
128 128
             // Register the manifest service
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     /**
159 159
      * @var array The URIs for the element before it was saved
160 160
      */
161
-    public $oldElementUris = [];
161
+    public $oldElementUris = [ ];
162 162
 
163 163
     // Public Methods
164 164
     // =========================================================================
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             Craft::t(
192 192
                 'retour',
193 193
                 '{name} plugin loaded',
194
-                ['name' => $this->name]
194
+                [ 'name' => $this->name ]
195 195
             ),
196 196
             __METHOD__
197 197
         );
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function getCpNavItem()
213 213
     {
214
-        $subNavs = [];
214
+        $subNavs = [ ];
215 215
         $navItem = parent::getCpNavItem();
216 216
         $currentUser = Craft::$app->getUser()->getIdentity();
217 217
         // Only show sub-navs the user has permission to view
218 218
         if ($currentUser->can('retour:dashboard')) {
219
-            $subNavs['dashboard'] = [
219
+            $subNavs[ 'dashboard' ] = [
220 220
                 'label' => 'Dashboard',
221 221
                 'url' => 'retour/dashboard',
222 222
             ];
223 223
         }
224 224
         if ($currentUser->can('retour:redirects')) {
225
-            $subNavs['redirects'] = [
225
+            $subNavs[ 'redirects' ] = [
226 226
                 'label' => 'Redirects',
227 227
                 'url' => 'retour/redirects',
228 228
             ];
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
             $editableSettings = false;
234 234
         }
235 235
         if ($currentUser->can('retour:settings') && $editableSettings) {
236
-            $subNavs['settings'] = [
236
+            $subNavs[ 'settings' ] = [
237 237
                 'label' => 'Settings',
238 238
                 'url' => 'retour/settings',
239 239
             ];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         }
245 245
         // A single sub nav item is redundant
246 246
         if (count($subNavs) === 1) {
247
-            $subNavs = [];
247
+            $subNavs = [ ];
248 248
         }
249 249
         $navItem = array_merge($navItem, [
250 250
             'subnav' => $subNavs,
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         Event::on(
301 301
             ClearCaches::class,
302 302
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
303
-            function (RegisterCacheOptionsEvent $event) {
303
+            function(RegisterCacheOptionsEvent $event) {
304 304
                 Craft::debug(
305 305
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
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_INSTALL_PLUGIN,
319
-            function (PluginEvent $event) {
319
+            function(PluginEvent $event) {
320 320
                 if ($event->plugin === $this) {
321 321
                     // Invalidate our caches after we've been installed
322 322
                     $this->clearAllCaches();
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         Event::on(
344 344
             CraftVariable::class,
345 345
             CraftVariable::EVENT_INIT,
346
-            function (Event $event) {
346
+            function(Event $event) {
347 347
                 /** @var CraftVariable $variable */
348 348
                 $variable = $event->sender;
349 349
                 $variable->set('retour', [
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         Event::on(
357 357
             Elements::class,
358 358
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
359
-            function (ElementEvent $event) {
359
+            function(ElementEvent $event) {
360 360
                 Craft::debug(
361 361
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
362 362
                     __METHOD__
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
380 380
                             // Stash the old URLs by element id, and do so only once,
381 381
                             // in case we are called more than once per request
382
-                            if (empty($this->oldElementUris[$element->id])) {
383
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
382
+                            if (empty($this->oldElementUris[ $element->id ])) {
383
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
384 384
                             }
385 385
                         }
386 386
                     }
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
         Event::on(
392 392
             Elements::class,
393 393
             Elements::EVENT_AFTER_SAVE_ELEMENT,
394
-            function (ElementEvent $event) {
394
+            function(ElementEvent $event) {
395 395
                 Craft::debug(
396 396
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
397 397
                     __METHOD__
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
         Event::on(
414 414
             Plugins::class,
415 415
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
416
-            function () {
416
+            function() {
417 417
                 // Install these only after all other plugins have loaded
418 418
                 $request = Craft::$app->getRequest();
419 419
                 // Only respond to non-console site requests
@@ -431,26 +431,26 @@  discard block
 block discarded – undo
431 431
             Event::on(
432 432
                 Gql::class,
433 433
                 Gql::EVENT_REGISTER_GQL_TYPES,
434
-                function (RegisterGqlTypesEvent $event) {
434
+                function(RegisterGqlTypesEvent $event) {
435 435
                     Craft::debug(
436 436
                         'Gql::EVENT_REGISTER_GQL_TYPES',
437 437
                         __METHOD__
438 438
                     );
439
-                    $event->types[] = RetourInterface::class;
439
+                    $event->types[ ] = RetourInterface::class;
440 440
                 }
441 441
             );
442 442
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
443 443
             Event::on(
444 444
                 Gql::class,
445 445
                 Gql::EVENT_REGISTER_GQL_QUERIES,
446
-                function (RegisterGqlQueriesEvent $event) {
446
+                function(RegisterGqlQueriesEvent $event) {
447 447
                     Craft::debug(
448 448
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
449 449
                         __METHOD__
450 450
                     );
451 451
                     $queries = RetourQuery::getQueries();
452 452
                     foreach ($queries as $key => $value) {
453
-                        $event->queries[$key] = $value;
453
+                        $event->queries[ $key ] = $value;
454 454
                     }
455 455
                 }
456 456
             );
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
             Event::on(
459 459
                 Gql::class,
460 460
                 Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS,
461
-                function (RegisterGqlSchemaComponentsEvent $event) {
461
+                function(RegisterGqlSchemaComponentsEvent $event) {
462 462
                     Craft::debug(
463 463
                         'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS',
464 464
                         __METHOD__
465 465
                     );
466 466
                     $label = Craft::t('retour', 'Retour');
467
-                    $event->queries[$label]['retour.all:read'] = ['label' => Craft::t('retour', 'Query Retour data')];
467
+                    $event->queries[ $label ][ 'retour.all:read' ] = [ 'label' => Craft::t('retour', 'Query Retour data') ];
468 468
                 }
469 469
             );
470 470
         }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             Event::on(
474 474
                 Schema::class,
475 475
                 AlterSchemaFields::EVENT,
476
-                [GetCraftQLSchema::class, 'handle']
476
+                [ GetCraftQLSchema::class, 'handle' ]
477 477
             );
478 478
         }
479 479
     }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         Event::on(
488 488
             UrlManager::class,
489 489
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
490
-            function (RegisterUrlRulesEvent $event) {
490
+            function(RegisterUrlRulesEvent $event) {
491 491
                 Craft::debug(
492 492
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
493 493
                     __METHOD__
@@ -510,15 +510,15 @@  discard block
 block discarded – undo
510 510
         Event::on(
511 511
             Dashboard::class,
512 512
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
513
-            function (RegisterComponentTypesEvent $event) {
514
-                $event->types[] = RetourWidget::class;
513
+            function(RegisterComponentTypesEvent $event) {
514
+                $event->types[ ] = RetourWidget::class;
515 515
             }
516 516
         );
517 517
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
518 518
         Event::on(
519 519
             UrlManager::class,
520 520
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
521
-            function (RegisterUrlRulesEvent $event) {
521
+            function(RegisterUrlRulesEvent $event) {
522 522
                 Craft::debug(
523 523
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
524 524
                     __METHOD__
@@ -534,13 +534,13 @@  discard block
 block discarded – undo
534 534
         Event::on(
535 535
             UserPermissions::class,
536 536
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
537
-            function (RegisterUserPermissionsEvent $event) {
537
+            function(RegisterUserPermissionsEvent $event) {
538 538
                 Craft::debug(
539 539
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
540 540
                     __METHOD__
541 541
                 );
542 542
                 // Register our custom permissions
543
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
543
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
544 544
             }
545 545
         );
546 546
     }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         Event::on(
557 557
             ErrorHandler::class,
558 558
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
559
-            function (ExceptionEvent $event) {
559
+            function(ExceptionEvent $event) {
560 560
                 Craft::debug(
561 561
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
562 562
                     __METHOD__
@@ -599,16 +599,16 @@  discard block
 block discarded – undo
599 599
     protected function handleElementUriChange(Element $element)
600 600
     {
601 601
         $uris = $this->getAllElementUris($element);
602
-        if (!empty($this->oldElementUris[$element->id])) {
603
-            $oldElementUris = $this->oldElementUris[$element->id];
602
+        if (!empty($this->oldElementUris[ $element->id ])) {
603
+            $oldElementUris = $this->oldElementUris[ $element->id ];
604 604
             foreach ($uris as $siteId => $newUri) {
605
-                if (!empty($oldElementUris[$siteId])) {
606
-                    $oldUri = $oldElementUris[$siteId];
605
+                if (!empty($oldElementUris[ $siteId ])) {
606
+                    $oldUri = $oldElementUris[ $siteId ];
607 607
                     Craft::debug(
608 608
                         Craft::t(
609 609
                             'retour',
610 610
                             'Comparing old: {oldUri} to new: {newUri}',
611
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
611
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
612 612
                         ),
613 613
                         __METHOD__
614 614
                     );
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
                         if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') {
629 629
                             try {
630 630
                                 if ($redirectSiteId !== null) {
631
-                                    $redirectSiteId = (int)$redirectSiteId;
631
+                                    $redirectSiteId = (int) $redirectSiteId;
632 632
                                 }
633 633
                                 $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId);
634 634
                                 $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId);
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
      */
662 662
     protected function getAllElementUris(Element $element): array
663 663
     {
664
-        $uris = [];
664
+        $uris = [ ];
665 665
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
666 666
             $sites = Craft::$app->getSites()->getAllSites();
667 667
             foreach ($sites as $site) {
668 668
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
669 669
                 if ($uri !== null) {
670
-                    $uris[$site->id] = $uri;
670
+                    $uris[ $site->id ] = $uri;
671 671
                 }
672 672
             }
673 673
         }
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
             Craft::t(
677 677
                 'retour',
678 678
                 'Getting Element URIs: {uris}',
679
-                ['uris' => print_r($uris, true)]
679
+                [ 'uris' => print_r($uris, true) ]
680 680
             ),
681 681
             __METHOD__
682 682
         );
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
             [
732 732
                 'key' => 'retour-redirect-caches',
733 733
                 'label' => Craft::t('retour', 'Retour redirect caches'),
734
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
734
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
735 735
             ],
736 736
         ];
737 737
     }
Please login to merge, or discard this patch.