@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | try { |
257 | 257 | $siteId = $redirect['siteId'] ?? null; |
258 | 258 | if ($siteId !== null) { |
259 | - $siteId = (int)$siteId; |
|
259 | + $siteId = (int) $siteId; |
|
260 | 260 | } |
261 | 261 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId); |
262 | 262 | } catch (\yii\base\Exception $e) { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | // That's ok |
272 | 272 | } |
273 | 273 | if (!empty($queryString)) { |
274 | - $dest = strtok($dest, '?') . '?' . $queryString; |
|
274 | + $dest = strtok($dest, '?').'?'.$queryString; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | public function getRedirectFromCache($url, int $siteId = 0) |
389 | 389 | { |
390 | 390 | $cache = Craft::$app->getCache(); |
391 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
391 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
392 | 392 | $redirect = $cache->get($cacheKey); |
393 | 393 | Craft::info( |
394 | 394 | Craft::t( |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | } catch (SiteNotFoundException $e) { |
417 | 417 | $siteId = 1; |
418 | 418 | } |
419 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
419 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
420 | 420 | // Create the dependency tags |
421 | 421 | $dependency = new TagDependency([ |
422 | 422 | 'tags' => [ |
423 | 423 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
424 | - $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
424 | + $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
425 | 425 | ], |
426 | 426 | ]); |
427 | 427 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | foreach ($redirects as $redirect) { |
462 | 462 | // Figure out what type of source matching to do |
463 | 463 | $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
464 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
464 | + $redirectEnabled = (bool) $redirect['enabled']; |
|
465 | 465 | if ($redirectEnabled === true) { |
466 | 466 | switch ($redirectSrcMatch) { |
467 | 467 | case 'pathonly': |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | |
503 | 503 | // Do a regex match |
504 | 504 | case 'regexmatch': |
505 | - $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i'; |
|
505 | + $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
506 | 506 | try { |
507 | 507 | if (preg_match($matchRegEx, $url) === 1) { |
508 | 508 | $this->incrementRedirectHitCount($redirect); |
509 | 509 | // If we're not associated with an EntryID, handle capture group replacement |
510 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
510 | + if ((int) $redirect['associatedElementId'] === 0) { |
|
511 | 511 | $redirect['redirectDestUrl'] = preg_replace( |
512 | 512 | $matchRegEx, |
513 | 513 | $redirect['redirectDestUrl'], |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | } |
536 | 536 | } catch (\Exception $e) { |
537 | 537 | // That's fine |
538 | - Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__); |
|
538 | + Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | break; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
644 | 644 | /** @var Plugin $plugin */ |
645 | 645 | if (method_exists($plugin, 'retourMatch')) { |
646 | - $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match'); |
|
646 | + $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | 'id' => $redirectConfig['id'], |
913 | 913 | ] |
914 | 914 | )->execute(); |
915 | - Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
915 | + Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
916 | 916 | } catch (\Exception $e) { |
917 | 917 | Craft::error($e->getMessage(), __METHOD__); |
918 | 918 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | // Get the validated model attributes and save them to the db |
1044 | 1044 | $redirectConfig = $redirect->getAttributes(); |
1045 | 1045 | // 0 for a siteId needs to be converted to null |
1046 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
1046 | + if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) { |
|
1047 | 1047 | $redirectConfig['siteId'] = null; |
1048 | 1048 | } |
1049 | 1049 | // Throw an event to before saving the redirect |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | // See if a redirect exists with this source URL already |
1056 | - if ((int)$redirectConfig['id'] === 0) { |
|
1056 | + if ((int) $redirectConfig['id'] === 0) { |
|
1057 | 1057 | // Query the db table |
1058 | 1058 | $redirect = (new Query()) |
1059 | 1059 | ->from(['{{%retour_static_redirects}}']) |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | // Trigger a 'beforeSaveRedirect' event |
1069 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
1069 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
1070 | 1070 | $event = new RedirectEvent([ |
1071 | 1071 | 'isNew' => $isNew, |
1072 | 1072 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -1169,17 +1169,17 @@ discard block |
||
1169 | 1169 | */ |
1170 | 1170 | public function excludeUri($uri): bool |
1171 | 1171 | { |
1172 | - $uri = '/' . ltrim($uri, '/'); |
|
1172 | + $uri = '/'.ltrim($uri, '/'); |
|
1173 | 1173 | if (!empty(Retour::$settings->excludePatterns)) { |
1174 | 1174 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
1175 | - $pattern = '`' . $excludePattern['pattern'] . '`i'; |
|
1175 | + $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
1176 | 1176 | try { |
1177 | 1177 | if (preg_match($pattern, $uri) === 1) { |
1178 | 1178 | return true; |
1179 | 1179 | } |
1180 | 1180 | } catch (\Exception $e) { |
1181 | 1181 | // That's fine |
1182 | - Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__); |
|
1182 | + Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__); |
|
1183 | 1183 | } |
1184 | 1184 | } |
1185 | 1185 | } |