@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function excludeUri($uri): bool |
| 274 | 274 | { |
| 275 | - $uri = '/' . ltrim($uri, '/'); |
|
| 275 | + $uri = '/'.ltrim($uri, '/'); |
|
| 276 | 276 | if (!empty(Retour::$settings->excludePatterns)) { |
| 277 | 277 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
| 278 | 278 | if (empty($excludePattern['pattern'])) { |
| 279 | 279 | continue; |
| 280 | 280 | } |
| 281 | - $pattern = '`' . $excludePattern['pattern'] . '`i'; |
|
| 281 | + $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
| 282 | 282 | try { |
| 283 | 283 | if (preg_match($pattern, $uri) === 1) { |
| 284 | 284 | Craft::info( |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | } catch (\Exception $e) { |
| 296 | 296 | // That's fine |
| 297 | - Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__); |
|
| 297 | + Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * |
| 310 | 310 | * @return bool|array|null |
| 311 | 311 | */ |
| 312 | - public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool|array|null |
|
| 312 | + public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool | array | null |
|
| 313 | 313 | { |
| 314 | 314 | // Get the current site |
| 315 | 315 | if ($siteId === null) { |
@@ -362,10 +362,10 @@ discard block |
||
| 362 | 362 | * |
| 363 | 363 | * @return bool|array |
| 364 | 364 | */ |
| 365 | - public function getRedirectFromCache(string $url, int $siteId = 0): bool|array |
|
| 365 | + public function getRedirectFromCache(string $url, int $siteId = 0): bool | array |
|
| 366 | 366 | { |
| 367 | 367 | $cache = Craft::$app->getCache(); |
| 368 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 368 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 369 | 369 | $redirect = $cache->get($cacheKey); |
| 370 | 370 | Craft::info( |
| 371 | 371 | Craft::t( |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | 'id' => $redirectConfig['id'], |
| 411 | 411 | ] |
| 412 | 412 | )->execute(); |
| 413 | - Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
| 413 | + Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
| 414 | 414 | } catch (\Exception $e) { |
| 415 | 415 | Craft::error($e->getMessage(), __METHOD__); |
| 416 | 416 | } |
@@ -431,12 +431,12 @@ discard block |
||
| 431 | 431 | } catch (SiteNotFoundException $e) { |
| 432 | 432 | $siteId = 1; |
| 433 | 433 | } |
| 434 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 434 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 435 | 435 | // Create the dependency tags |
| 436 | 436 | $dependency = new TagDependency([ |
| 437 | 437 | 'tags' => [ |
| 438 | 438 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
| 439 | - $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
| 439 | + $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
| 440 | 440 | ], |
| 441 | 441 | ]); |
| 442 | 442 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | foreach ($redirects as $redirect) { |
| 631 | 631 | // Figure out what type of source matching to do |
| 632 | 632 | $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
| 633 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
| 633 | + $redirectEnabled = (bool) $redirect['enabled']; |
|
| 634 | 634 | if ($redirectEnabled === true) { |
| 635 | 635 | switch ($redirectSrcMatch) { |
| 636 | 636 | case 'pathonly': |
@@ -671,12 +671,12 @@ discard block |
||
| 671 | 671 | |
| 672 | 672 | // Do a regex match |
| 673 | 673 | case 'regexmatch': |
| 674 | - $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i'; |
|
| 674 | + $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
| 675 | 675 | try { |
| 676 | 676 | if (preg_match($matchRegEx, $url) === 1) { |
| 677 | 677 | $this->incrementRedirectHitCount($redirect); |
| 678 | 678 | // If we're not associated with an EntryID, handle capture group replacement |
| 679 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
| 679 | + if ((int) $redirect['associatedElementId'] === 0) { |
|
| 680 | 680 | $redirect['redirectDestUrl'] = preg_replace( |
| 681 | 681 | $matchRegEx, |
| 682 | 682 | $redirect['redirectDestUrl'], |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | } catch (\Exception $e) { |
| 706 | 706 | // That's fine |
| 707 | - Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__); |
|
| 707 | + Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | break; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | try { |
| 830 | 830 | $siteId = $redirect['siteId'] ?? null; |
| 831 | 831 | if ($siteId !== null) { |
| 832 | - $siteId = (int)$siteId; |
|
| 832 | + $siteId = (int) $siteId; |
|
| 833 | 833 | } |
| 834 | 834 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId); |
| 835 | 835 | } catch (\yii\base\Exception $e) { |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | // That's ok |
| 845 | 845 | } |
| 846 | 846 | if (!empty($queryString)) { |
| 847 | - $dest = strtok($dest, '?') . '?' . $queryString; |
|
| 847 | + $dest = strtok($dest, '?').'?'.$queryString; |
|
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
| 913 | 913 | /** @var Plugin $plugin */ |
| 914 | 914 | if (method_exists($plugin, 'retourMatch')) { |
| 915 | - $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match'); |
|
| 915 | + $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
| 916 | 916 | } |
| 917 | 917 | } |
| 918 | 918 | |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | $db = Craft::$app->getDb(); |
| 950 | 950 | // Trigger a 'beforeDeleteRedirect' event |
| 951 | 951 | $redirectConfig = $this->getRedirectById($id); |
| 952 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 952 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 953 | 953 | $event = new RedirectEvent([ |
| 954 | 954 | 'isNew' => $isNew, |
| 955 | 955 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | // Get the validated model attributes and save them to the db |
| 1110 | 1110 | $redirectConfig = $redirect->getAttributes(); |
| 1111 | 1111 | // 0 for a siteId needs to be converted to null |
| 1112 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
| 1112 | + if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) { |
|
| 1113 | 1113 | $redirectConfig['siteId'] = null; |
| 1114 | 1114 | } |
| 1115 | 1115 | // Throw an event to before saving the redirect |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | // See if a redirect exists with this source URL already |
| 1122 | - if ((int)$redirectConfig['id'] === 0) { |
|
| 1122 | + if ((int) $redirectConfig['id'] === 0) { |
|
| 1123 | 1123 | // Query the db table |
| 1124 | 1124 | $redirect = (new Query()) |
| 1125 | 1125 | ->from(['{{%retour_static_redirects}}']) |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | } |
| 1133 | 1133 | } |
| 1134 | 1134 | // Trigger a 'beforeSaveRedirect' event |
| 1135 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 1135 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 1136 | 1136 | $event = new RedirectEvent([ |
| 1137 | 1137 | 'isNew' => $isNew, |
| 1138 | 1138 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |