@@ -280,13 +280,13 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | public function excludeUri($uri): bool |
| 282 | 282 | { |
| 283 | - $uri = '/' . ltrim($uri, '/'); |
|
| 283 | + $uri = '/'.ltrim($uri, '/'); |
|
| 284 | 284 | if (!empty(Retour::$settings->excludePatterns)) { |
| 285 | 285 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
| 286 | 286 | if (empty($excludePattern['pattern'])) { |
| 287 | 287 | continue; |
| 288 | 288 | } |
| 289 | - $pattern = '`' . $excludePattern['pattern'] . '`i'; |
|
| 289 | + $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
| 290 | 290 | try { |
| 291 | 291 | if (preg_match($pattern, $uri) === 1) { |
| 292 | 292 | Craft::info( |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | } catch (\Exception $e) { |
| 304 | 304 | // That's fine |
| 305 | - Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__); |
|
| 305 | + Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return bool|array|null |
| 319 | 319 | */ |
| 320 | - public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool|array|null |
|
| 320 | + public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool | array | null |
|
| 321 | 321 | { |
| 322 | 322 | // Get the current site |
| 323 | 323 | if ($siteId === null) { |
@@ -370,10 +370,10 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @return bool|array |
| 372 | 372 | */ |
| 373 | - public function getRedirectFromCache(string $url, int $siteId = 0): bool|array |
|
| 373 | + public function getRedirectFromCache(string $url, int $siteId = 0): bool | array |
|
| 374 | 374 | { |
| 375 | 375 | $cache = Craft::$app->getCache(); |
| 376 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 376 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 377 | 377 | $redirect = $cache->get($cacheKey); |
| 378 | 378 | Craft::info( |
| 379 | 379 | Craft::t( |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | 'id' => $redirectConfig['id'], |
| 419 | 419 | ] |
| 420 | 420 | )->execute(); |
| 421 | - Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
| 421 | + Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
| 422 | 422 | } catch (\Exception $e) { |
| 423 | 423 | Craft::error($e->getMessage(), __METHOD__); |
| 424 | 424 | } |
@@ -439,12 +439,12 @@ discard block |
||
| 439 | 439 | } catch (SiteNotFoundException $e) { |
| 440 | 440 | $siteId = 1; |
| 441 | 441 | } |
| 442 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 442 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 443 | 443 | // Create the dependency tags |
| 444 | 444 | $dependency = new TagDependency([ |
| 445 | 445 | 'tags' => [ |
| 446 | 446 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
| 447 | - $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
| 447 | + $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
| 448 | 448 | ], |
| 449 | 449 | ]); |
| 450 | 450 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | foreach ($redirects as $redirect) { |
| 639 | 639 | // Figure out what type of source matching to do |
| 640 | 640 | $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
| 641 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
| 641 | + $redirectEnabled = (bool) $redirect['enabled']; |
|
| 642 | 642 | if ($redirectEnabled === true) { |
| 643 | 643 | switch ($redirectSrcMatch) { |
| 644 | 644 | case 'pathonly': |
@@ -679,12 +679,12 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | // Do a regex match |
| 681 | 681 | case 'regexmatch': |
| 682 | - $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i'; |
|
| 682 | + $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
| 683 | 683 | try { |
| 684 | 684 | if (preg_match($matchRegEx, $url) === 1) { |
| 685 | 685 | $this->incrementRedirectHitCount($redirect); |
| 686 | 686 | // If we're not associated with an EntryID, handle capture group replacement |
| 687 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
| 687 | + if ((int) $redirect['associatedElementId'] === 0) { |
|
| 688 | 688 | $redirect['redirectDestUrl'] = preg_replace( |
| 689 | 689 | $matchRegEx, |
| 690 | 690 | $redirect['redirectDestUrl'], |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | } |
| 713 | 713 | } catch (\Exception $e) { |
| 714 | 714 | // That's fine |
| 715 | - Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__); |
|
| 715 | + Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | break; |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | try { |
| 829 | 829 | $siteId = $redirect['siteId'] ?? null; |
| 830 | 830 | if ($siteId !== null) { |
| 831 | - $siteId = (int)$siteId; |
|
| 831 | + $siteId = (int) $siteId; |
|
| 832 | 832 | } |
| 833 | 833 | if (!UrlHelper::isAbsoluteUrl($dest) && !UrlHelper::pathHasSitePrefix($path) && Retour::$settings->resolveCraftSites) { |
| 834 | 834 | $dest = UrlHelper::siteUrl('/', null, null, $siteId); |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | try { |
| 851 | 851 | $siteId = $redirect['siteId'] ?? null; |
| 852 | 852 | if ($siteId !== null) { |
| 853 | - $siteId = (int)$siteId; |
|
| 853 | + $siteId = (int) $siteId; |
|
| 854 | 854 | } |
| 855 | 855 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId); |
| 856 | 856 | } catch (\yii\base\Exception $e) { |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | // That's ok |
| 866 | 866 | } |
| 867 | 867 | if (!empty($queryString)) { |
| 868 | - $dest = strtok($dest, '?') . '?' . $queryString; |
|
| 868 | + $dest = strtok($dest, '?').'?'.$queryString; |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
| 940 | 940 | /** @var Plugin $plugin */ |
| 941 | 941 | if (method_exists($plugin, 'retourMatch')) { |
| 942 | - $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match'); |
|
| 942 | + $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | $db = Craft::$app->getDb(); |
| 977 | 977 | // Trigger a 'beforeDeleteRedirect' event |
| 978 | 978 | $redirectConfig = $this->getRedirectById($id); |
| 979 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 979 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 980 | 980 | $event = new RedirectEvent([ |
| 981 | 981 | 'isNew' => $isNew, |
| 982 | 982 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | // Get the validated model attributes and save them to the db |
| 1141 | 1141 | $redirectConfig = $redirect->getAttributes(); |
| 1142 | 1142 | // 0 for a siteId needs to be converted to null |
| 1143 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
| 1143 | + if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) { |
|
| 1144 | 1144 | $redirectConfig['siteId'] = null; |
| 1145 | 1145 | } |
| 1146 | 1146 | // Throw an event to before saving the redirect |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | // See if a redirect exists with this source URL already |
| 1153 | - if ((int)$redirectConfig['id'] === 0) { |
|
| 1153 | + if ((int) $redirectConfig['id'] === 0) { |
|
| 1154 | 1154 | // Query the db table |
| 1155 | 1155 | $redirect = (new Query()) |
| 1156 | 1156 | ->from(['{{%retour_static_redirects}}']) |
@@ -1163,7 +1163,7 @@ discard block |
||
| 1163 | 1163 | } |
| 1164 | 1164 | } |
| 1165 | 1165 | // Trigger a 'beforeSaveRedirect' event |
| 1166 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 1166 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 1167 | 1167 | $event = new RedirectEvent([ |
| 1168 | 1168 | 'isNew' => $isNew, |
| 1169 | 1169 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |