@@ -61,7 +61,7 @@ |
||
61 | 61 | /** @noinspection CallableParameterUseCaseInTypeContextInspection */ |
62 | 62 | $url = preg_replace('/{.*}/', '', $url); |
63 | 63 | // Remove any linebreaks that may be errantly in the URL |
64 | - $url = (string)str_replace([ |
|
64 | + $url = (string) str_replace([ |
|
65 | 65 | PHP_EOL, |
66 | 66 | "\r", |
67 | 67 | "\n", |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | try { |
254 | 254 | $siteId = $redirect['siteId'] ?? null; |
255 | 255 | if ($siteId !== null) { |
256 | - $siteId = (int)$siteId; |
|
256 | + $siteId = (int) $siteId; |
|
257 | 257 | } |
258 | 258 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId); |
259 | 259 | } catch (\yii\base\Exception $e) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | // That's ok |
269 | 269 | } |
270 | 270 | if (!empty($queryString)) { |
271 | - $dest = strtok($dest, '?') . '?' . $queryString; |
|
271 | + $dest = strtok($dest, '?').'?'.$queryString; |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | public function getRedirectFromCache($url, int $siteId = 0) |
386 | 386 | { |
387 | 387 | $cache = Craft::$app->getCache(); |
388 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
388 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
389 | 389 | $redirect = $cache->get($cacheKey); |
390 | 390 | Craft::info( |
391 | 391 | Craft::t( |
@@ -413,12 +413,12 @@ discard block |
||
413 | 413 | } catch (SiteNotFoundException $e) { |
414 | 414 | $siteId = 1; |
415 | 415 | } |
416 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
416 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
417 | 417 | // Create the dependency tags |
418 | 418 | $dependency = new TagDependency([ |
419 | 419 | 'tags' => [ |
420 | 420 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
421 | - $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
421 | + $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
422 | 422 | ], |
423 | 423 | ]); |
424 | 424 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | foreach ($redirects as $redirect) { |
459 | 459 | // Figure out what type of source matching to do |
460 | 460 | $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
461 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
461 | + $redirectEnabled = (bool) $redirect['enabled']; |
|
462 | 462 | if ($redirectEnabled === true) { |
463 | 463 | switch ($redirectSrcMatch) { |
464 | 464 | case 'pathonly': |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | |
500 | 500 | // Do a regex match |
501 | 501 | case 'regexmatch': |
502 | - $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i'; |
|
502 | + $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
503 | 503 | try { |
504 | 504 | if (preg_match($matchRegEx, $url) === 1) { |
505 | 505 | $this->incrementRedirectHitCount($redirect); |
506 | 506 | // If we're not associated with an EntryID, handle capture group replacement |
507 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
507 | + if ((int) $redirect['associatedElementId'] === 0) { |
|
508 | 508 | $redirect['redirectDestUrl'] = preg_replace( |
509 | 509 | $matchRegEx, |
510 | 510 | $redirect['redirectDestUrl'], |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | } |
533 | 533 | } catch (\Exception $e) { |
534 | 534 | // That's fine |
535 | - Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__); |
|
535 | + Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | break; |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
641 | 641 | /** @var Plugin $plugin */ |
642 | 642 | if (method_exists($plugin, 'retourMatch')) { |
643 | - $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match'); |
|
643 | + $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | 'id' => $redirectConfig['id'], |
910 | 910 | ] |
911 | 911 | )->execute(); |
912 | - Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
912 | + Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
913 | 913 | } catch (\Exception $e) { |
914 | 914 | Craft::error($e->getMessage(), __METHOD__); |
915 | 915 | } |
@@ -983,13 +983,13 @@ discard block |
||
983 | 983 | // Get the validated model attributes and save them to the db |
984 | 984 | $redirectConfig = $redirect->getAttributes(); |
985 | 985 | // 0 for a siteId needs to be converted to null |
986 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
986 | + if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) { |
|
987 | 987 | $redirectConfig['siteId'] = null; |
988 | 988 | } |
989 | 989 | // Throw an event to before saving the redirect |
990 | 990 | $db = Craft::$app->getDb(); |
991 | 991 | // See if a redirect exists with this source URL already |
992 | - if ((int)$redirectConfig['id'] === 0) { |
|
992 | + if ((int) $redirectConfig['id'] === 0) { |
|
993 | 993 | // Query the db table |
994 | 994 | $redirect = (new Query()) |
995 | 995 | ->from(['{{%retour_static_redirects}}']) |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | } |
1003 | 1003 | } |
1004 | 1004 | // Trigger a 'beforeSaveRedirect' event |
1005 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
1005 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
1006 | 1006 | $event = new RedirectEvent([ |
1007 | 1007 | 'isNew' => $isNew, |
1008 | 1008 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -1118,17 +1118,17 @@ discard block |
||
1118 | 1118 | */ |
1119 | 1119 | public function excludeUri($uri): bool |
1120 | 1120 | { |
1121 | - $uri = '/' . ltrim($uri, '/'); |
|
1121 | + $uri = '/'.ltrim($uri, '/'); |
|
1122 | 1122 | if (!empty(Retour::$settings->excludePatterns)) { |
1123 | 1123 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
1124 | - $pattern = '`' . $excludePattern['pattern'] . '`i'; |
|
1124 | + $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
1125 | 1125 | try { |
1126 | 1126 | if (preg_match($pattern, $uri) === 1) { |
1127 | 1127 | return true; |
1128 | 1128 | } |
1129 | 1129 | } catch (\Exception $e) { |
1130 | 1130 | // That's fine |
1131 | - Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__); |
|
1131 | + Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__); |
|
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | } |