@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | Event::on( |
| 310 | 310 | ClearCaches::class, |
| 311 | 311 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 312 | - function (RegisterCacheOptionsEvent $event) { |
|
| 312 | + function(RegisterCacheOptionsEvent $event) { |
|
| 313 | 313 | Craft::debug( |
| 314 | 314 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 315 | 315 | __METHOD__ |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | Event::on( |
| 326 | 326 | Plugins::class, |
| 327 | 327 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 328 | - function (PluginEvent $event) { |
|
| 328 | + function(PluginEvent $event) { |
|
| 329 | 329 | if ($event->plugin === $this) { |
| 330 | 330 | // Invalidate our caches after we've been installed |
| 331 | 331 | $this->clearAllCaches(); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | Event::on( |
| 353 | 353 | CraftVariable::class, |
| 354 | 354 | CraftVariable::EVENT_INIT, |
| 355 | - function (Event $event) { |
|
| 355 | + function(Event $event) { |
|
| 356 | 356 | /** @var CraftVariable $variable */ |
| 357 | 357 | $variable = $event->sender; |
| 358 | 358 | $variable->set('retour', [ |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | Event::on( |
| 366 | 366 | Elements::class, |
| 367 | 367 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 368 | - function (ElementEvent $event) { |
|
| 368 | + function(ElementEvent $event) { |
|
| 369 | 369 | Craft::debug( |
| 370 | 370 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 371 | 371 | __METHOD__ |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | Event::on( |
| 397 | 397 | Elements::class, |
| 398 | 398 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 399 | - function (ElementEvent $event) { |
|
| 399 | + function(ElementEvent $event) { |
|
| 400 | 400 | Craft::debug( |
| 401 | 401 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 402 | 402 | __METHOD__ |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | Event::on( |
| 419 | 419 | Plugins::class, |
| 420 | 420 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 421 | - function () { |
|
| 421 | + function() { |
|
| 422 | 422 | // Install these only after all other plugins have loaded |
| 423 | 423 | $request = Craft::$app->getRequest(); |
| 424 | 424 | // Only respond to non-console site requests |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | Event::on( |
| 436 | 436 | Fields::class, |
| 437 | 437 | Fields::EVENT_REGISTER_FIELD_TYPES, |
| 438 | - function (RegisterComponentTypesEvent $event) { |
|
| 438 | + function(RegisterComponentTypesEvent $event) { |
|
| 439 | 439 | $event->types[] = ShortLinkField::class; |
| 440 | 440 | } |
| 441 | 441 | ); |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | Event::on( |
| 445 | 445 | Gql::class, |
| 446 | 446 | Gql::EVENT_REGISTER_GQL_TYPES, |
| 447 | - function (RegisterGqlTypesEvent $event) { |
|
| 447 | + function(RegisterGqlTypesEvent $event) { |
|
| 448 | 448 | Craft::debug( |
| 449 | 449 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
| 450 | 450 | __METHOD__ |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | Event::on( |
| 457 | 457 | Gql::class, |
| 458 | 458 | Gql::EVENT_REGISTER_GQL_QUERIES, |
| 459 | - function (RegisterGqlQueriesEvent $event) { |
|
| 459 | + function(RegisterGqlQueriesEvent $event) { |
|
| 460 | 460 | Craft::debug( |
| 461 | 461 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
| 462 | 462 | __METHOD__ |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | Event::on( |
| 473 | 473 | Gql::class, |
| 474 | 474 | Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, |
| 475 | - function (RegisterGqlSchemaComponentsEvent $event) { |
|
| 475 | + function(RegisterGqlSchemaComponentsEvent $event) { |
|
| 476 | 476 | Craft::debug( |
| 477 | 477 | 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', |
| 478 | 478 | __METHOD__ |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | Event::on( |
| 503 | 503 | UrlManager::class, |
| 504 | 504 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 505 | - function (RegisterUrlRulesEvent $event) { |
|
| 505 | + function(RegisterUrlRulesEvent $event) { |
|
| 506 | 506 | Craft::debug( |
| 507 | 507 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 508 | 508 | __METHOD__ |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | Event::on( |
| 526 | 526 | Dashboard::class, |
| 527 | 527 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 528 | - function (RegisterComponentTypesEvent $event) { |
|
| 528 | + function(RegisterComponentTypesEvent $event) { |
|
| 529 | 529 | $event->types[] = RetourWidget::class; |
| 530 | 530 | } |
| 531 | 531 | ); |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | Event::on( |
| 534 | 534 | UrlManager::class, |
| 535 | 535 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 536 | - function (RegisterUrlRulesEvent $event) { |
|
| 536 | + function(RegisterUrlRulesEvent $event) { |
|
| 537 | 537 | Craft::debug( |
| 538 | 538 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 539 | 539 | __METHOD__ |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | Event::on( |
| 550 | 550 | UserPermissions::class, |
| 551 | 551 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 552 | - function (RegisterUserPermissionsEvent $event) { |
|
| 552 | + function(RegisterUserPermissionsEvent $event) { |
|
| 553 | 553 | Craft::debug( |
| 554 | 554 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 555 | 555 | __METHOD__ |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | Event::on( |
| 572 | 572 | ErrorHandler::class, |
| 573 | 573 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 574 | - function (ExceptionEvent $event) { |
|
| 574 | + function(ExceptionEvent $event) { |
|
| 575 | 575 | Craft::debug( |
| 576 | 576 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 577 | 577 | __METHOD__ |
@@ -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 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | string $sort = 'hitCount|desc', |
| 91 | 91 | int $page = 1, |
| 92 | 92 | int $per_page = 20, |
| 93 | - $filter = '', |
|
| 94 | - $siteId = 0, |
|
| 95 | - $handled = 'all' |
|
| 93 | + $filter = '', |
|
| 94 | + $siteId = 0, |
|
| 95 | + $handled = 'all' |
|
| 96 | 96 | ): Response |
| 97 | 97 | { |
| 98 | 98 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | string $sort = 'hitCount|desc', |
| 187 | 187 | int $page = 1, |
| 188 | 188 | int $per_page = 20, |
| 189 | - $filter = '', |
|
| 190 | - $siteId = 0, |
|
| 191 | - $shortLinks = false |
|
| 189 | + $filter = '', |
|
| 190 | + $siteId = 0, |
|
| 191 | + $shortLinks = false |
|
| 192 | 192 | ): Response |
| 193 | 193 | { |
| 194 | 194 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | ->orderBy([$sortField => $sortType]) |
| 123 | 123 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
| 124 | 124 | ->orFilterWhere(['like', 'referrerUrl', $filter]); |
| 125 | - if ((int)$siteId !== 0) { |
|
| 125 | + if ((int) $siteId !== 0) { |
|
| 126 | 126 | $query->andWhere(['siteId' => $siteId]); |
| 127 | 127 | } |
| 128 | 128 | if ($handled !== 'all') { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | foreach ($stats as &$stat) { |
| 135 | 135 | $stat['addLink'] = ''; |
| 136 | 136 | if (!$stat['handledByRetour']) { |
| 137 | - $encodedUrl = urlencode('/' . ltrim($stat['redirectSrcUrl'], '/')); |
|
| 137 | + $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); |
|
| 138 | 138 | // Add the siteId to the URL, but keep the current behavior of passing in siteId=0 for "all" |
| 139 | 139 | $statSiteId = $stat['siteId'] ?? 0; |
| 140 | 140 | try { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | } catch (SiteNotFoundException $e) { |
| 143 | 143 | $primarySite = null; |
| 144 | 144 | } |
| 145 | - if ($primarySite !== null && $statSiteId == (int)$primarySite->id) { |
|
| 145 | + if ($primarySite !== null && $statSiteId == (int) $primarySite->id) { |
|
| 146 | 146 | $statSiteId = 0; |
| 147 | 147 | } |
| 148 | 148 | $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | ->orderBy([$sortField => $sortType]) |
| 219 | 219 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
| 220 | 220 | ->orFilterWhere(['like', 'redirectDestUrl', $filter]); |
| 221 | - if ((int)$siteId !== 0) { |
|
| 221 | + if ((int) $siteId !== 0) { |
|
| 222 | 222 | $query->andWhere(['siteId' => $siteId]); |
| 223 | 223 | } |
| 224 | 224 | if ($shortLinks) { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect['id']); |
|
| 248 | + $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); |
|
| 249 | 249 | } |
| 250 | 250 | // Format the data for the API |
| 251 | 251 | if ($redirects) { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
| 82 | 82 | $variables['pluginName'] = $pluginName; |
| 83 | 83 | $variables['title'] = $templateTitle; |
| 84 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
| 84 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
| 85 | 85 | $variables['crumbs'] = [ |
| 86 | 86 | [ |
| 87 | 87 | 'label' => $pluginName, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ], |
| 90 | 90 | [ |
| 91 | 91 | 'label' => $templateTitle, |
| 92 | - 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
| 92 | + 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
| 93 | 93 | ], |
| 94 | 94 | ]; |
| 95 | 95 | $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | if ($redirect->siteId) { |
| 151 | 151 | $site = $sites->getSiteById($redirect->siteId); |
| 152 | 152 | if ($site) { |
| 153 | - MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
| 153 | + MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | if ($siteId) { |
| 157 | 157 | $site = $sites->getSiteById($siteId); |
| 158 | 158 | if ($site) { |
| 159 | - MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
| 159 | + MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | $pluginName = Retour::$settings->pluginName; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | ], |
| 193 | 193 | [ |
| 194 | 194 | 'label' => $templateTitle, |
| 195 | - 'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId), |
|
| 195 | + 'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId), |
|
| 196 | 196 | ], |
| 197 | 197 | ]; |
| 198 | 198 | $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | if ($redirectConfig === null) { |
| 251 | 251 | throw new NotFoundHttpException('Redirect not found'); |
| 252 | 252 | } |
| 253 | - $redirectConfig['id'] = (int)$redirectConfig['id']; |
|
| 253 | + $redirectConfig['id'] = (int) $redirectConfig['id']; |
|
| 254 | 254 | // Handle enforcing trailing slashes |
| 255 | 255 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 256 | 256 | if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') { |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
| 335 | 335 | $variables['pluginName'] = $pluginName; |
| 336 | 336 | $variables['title'] = $templateTitle; |
| 337 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
| 337 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
| 338 | 338 | $variables['crumbs'] = [ |
| 339 | 339 | [ |
| 340 | 340 | 'label' => $pluginName, |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | ], |
| 343 | 343 | [ |
| 344 | 344 | 'label' => $templateTitle, |
| 345 | - 'url' => UrlHelper::cpUrl('retour/shortlinks' . $siteHandleUri), |
|
| 345 | + 'url' => UrlHelper::cpUrl('retour/shortlinks'.$siteHandleUri), |
|
| 346 | 346 | ], |
| 347 | 347 | ]; |
| 348 | 348 | $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
@@ -397,13 +397,13 @@ discard block |
||
| 397 | 397 | if (!preg_match('/\.[^\/]+$/', $url) && strpos($url, '?') === false) { |
| 398 | 398 | // If it's a root relative URL, assume it's a site URL |
| 399 | 399 | if (UrlHelper::isRootRelativeUrl($url)) { |
| 400 | - return rtrim($url, '/') . '/'; |
|
| 400 | + return rtrim($url, '/').'/'; |
|
| 401 | 401 | } |
| 402 | 402 | // If the URL matches any of the site's base URLs, assume it's a site URL |
| 403 | 403 | $sites = Craft::$app->getSites()->getAllSites(); |
| 404 | 404 | foreach ($sites as $site) { |
| 405 | 405 | if (strpos($url, $site->getBaseUrl()) === 0) { |
| 406 | - return rtrim($url, '/') . '/'; |
|
| 406 | + return rtrim($url, '/').'/'; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
| 194 | 194 | $variables['pluginName'] = $pluginName; |
| 195 | 195 | $variables['title'] = $templateTitle; |
| 196 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
| 196 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
| 197 | 197 | $variables['crumbs'] = [ |
| 198 | 198 | [ |
| 199 | 199 | 'label' => $pluginName, |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | ], |
| 202 | 202 | [ |
| 203 | 203 | 'label' => 'Redirects', |
| 204 | - 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
| 204 | + 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
| 205 | 205 | ], |
| 206 | 206 | ]; |
| 207 | 207 | $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $file = UploadedFile::getInstanceByName('file'); |
| 212 | 212 | if ($file !== null) { |
| 213 | 213 | $filename = uniqid($file->name, true); |
| 214 | - $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; |
|
| 214 | + $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename; |
|
| 215 | 215 | $file->saveAs($filePath, false); |
| 216 | 216 | // Also save the file to the cache as a backup way to access it |
| 217 | 217 | $cache = Craft::$app->getCache(); |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | $csv->insertOne(array_values($columns)); |
| 341 | 341 | $csv->insertAll($data); |
| 342 | - $csv->output($filename . '.csv'); |
|
| 342 | + $csv->output($filename.'.csv'); |
|
| 343 | 343 | exit(0); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $csv->setOffset(1); |
| 356 | 356 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
| 357 | 357 | $rowIndex = 1; |
| 358 | - $csv->each(function ($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
| 358 | + $csv->each(function($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
| 359 | 359 | $redirectConfig = [ |
| 360 | 360 | 'id' => 0, |
| 361 | 361 | ]; |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | $index++; |
| 370 | 370 | } |
| 371 | 371 | $redirectDump = print_r($redirectConfig, true); |
| 372 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 372 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 373 | 373 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
| 374 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 374 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 375 | 375 | $hasErrors = true; |
| 376 | 376 | } |
| 377 | 377 | $rowIndex++; |
@@ -411,9 +411,9 @@ discard block |
||
| 411 | 411 | $index++; |
| 412 | 412 | } |
| 413 | 413 | $redirectDump = print_r($redirectConfig, true); |
| 414 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 414 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 415 | 415 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
| 416 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 416 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 417 | 417 | $hasErrors = true; |
| 418 | 418 | } |
| 419 | 419 | $rowIndex++; |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | } |
| 98 | 98 | } else if (!empty($value) && !StringHelper::startsWith($value, 'http')) { |
| 99 | 99 | $siteUrl = $element->getSite()->getBaseUrl(); |
| 100 | - $value = rtrim($siteUrl, '/') . '/' . ltrim($value, '/'); |
|
| 100 | + $value = rtrim($siteUrl, '/').'/'.ltrim($value, '/'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | RetourPlugin::$plugin->redirects->removeElementRedirect($element, $this->redirectSrcMatch === 'pathonly'); |