@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | if (!empty($string)) { |
| 45 | 45 | $string = strip_tags($string); |
| 46 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
| 46 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return $result; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | if (!empty($string)) { |
| 69 | 69 | $string = strip_tags($string); |
| 70 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
| 70 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $result; |
@@ -5,12 +5,12 @@ |
||
| 5 | 5 | ini_set('date.timezone', 'UTC'); |
| 6 | 6 | |
| 7 | 7 | // Use the current installation of Craft |
| 8 | -define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage'); |
|
| 9 | -define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates'); |
|
| 10 | -define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config'); |
|
| 11 | -define('CRAFT_MIGRATIONS_PATH', __DIR__ . '/_craft/migrations'); |
|
| 12 | -define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations'); |
|
| 13 | -define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor'); |
|
| 8 | +define('CRAFT_STORAGE_PATH', __DIR__.'/_craft/storage'); |
|
| 9 | +define('CRAFT_TEMPLATES_PATH', __DIR__.'/_craft/templates'); |
|
| 10 | +define('CRAFT_CONFIG_PATH', __DIR__.'/_craft/config'); |
|
| 11 | +define('CRAFT_MIGRATIONS_PATH', __DIR__.'/_craft/migrations'); |
|
| 12 | +define('CRAFT_TRANSLATIONS_PATH', __DIR__.'/_craft/translations'); |
|
| 13 | +define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); |
|
| 14 | 14 | define('CRAFT_TESTS_PATH', __DIR__); |
| 15 | 15 | |
| 16 | 16 | $devMode = true; |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | if (strcmp($oldUri, $newUri) !== 0) { |
| 103 | 103 | // Handle trailing slash config setting |
| 104 | 104 | if (Craft::$app->config->general->addTrailingSlashesToUrls) { |
| 105 | - $oldUri = rtrim($oldUri, '/') . '/'; |
|
| 106 | - $newUri = rtrim($newUri, '/') . '/'; |
|
| 105 | + $oldUri = rtrim($oldUri, '/').'/'; |
|
| 106 | + $newUri = rtrim($newUri, '/').'/'; |
|
| 107 | 107 | } |
| 108 | 108 | // Handle the URL match type |
| 109 | 109 | if (Retour::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
| 110 | 110 | try { |
| 111 | 111 | if ($redirectSiteId !== null) { |
| 112 | - $redirectSiteId = (int)$redirectSiteId; |
|
| 112 | + $redirectSiteId = (int) $redirectSiteId; |
|
| 113 | 113 | } |
| 114 | 114 | $oldUri = \craft\helpers\UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
| 115 | 115 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | 'siteId' => $redirectSiteId, |
| 128 | 128 | ]; |
| 129 | 129 | // Trigger a 'beforeSaveEntryRedirect' event |
| 130 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 130 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 131 | 131 | $event = new RedirectEvent([ |
| 132 | 132 | 'isNew' => $isNew, |
| 133 | 133 | 'legacyUrl' => $redirectConfig['redirectSrcUrl'], |
@@ -41,17 +41,17 @@ |
||
| 41 | 41 | $retourType = GqlEntityRegistry::getEntity($typeName) |
| 42 | 42 | ?: GqlEntityRegistry::createEntity($typeName, new RetourType([ |
| 43 | 43 | 'name' => $typeName, |
| 44 | - 'args' => function () use ($retourArgs) { |
|
| 44 | + 'args' => function() use ($retourArgs) { |
|
| 45 | 45 | return $retourArgs; |
| 46 | 46 | }, |
| 47 | - 'fields' => function () use ($retourFields) { |
|
| 47 | + 'fields' => function() use ($retourFields) { |
|
| 48 | 48 | return $retourFields; |
| 49 | 49 | }, |
| 50 | 50 | 'description' => 'This entity has all the Retour fields', |
| 51 | 51 | ])); |
| 52 | 52 | |
| 53 | 53 | $gqlTypes[$typeName] = $retourType; |
| 54 | - TypeLoader::registerType($typeName, function () use ($retourType) { |
|
| 54 | + TypeLoader::registerType($typeName, function() use ($retourType) { |
|
| 55 | 55 | return $retourType; |
| 56 | 56 | }); |
| 57 | 57 | |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | 'retour' => [ |
| 42 | 42 | 'type' => RetourInterface::getType(), |
| 43 | 43 | 'args' => RetourArguments::getArguments(), |
| 44 | - 'resolve' => RetourResolver::class . '::resolve', |
|
| 44 | + 'resolve' => RetourResolver::class.'::resolve', |
|
| 45 | 45 | 'description' => 'This query is used to query for Retour redirects.', |
| 46 | 46 | 'deprecationReason' => 'This query is deprecated and will be removed in the future. You should use `retourResolveRedirect` instead.', |
| 47 | 47 | ], |
| 48 | 48 | 'retourResolveRedirect' => [ |
| 49 | 49 | 'type' => RetourInterface::getType(), |
| 50 | 50 | 'args' => RetourArguments::getArguments(), |
| 51 | - 'resolve' => RetourResolver::class . '::resolve', |
|
| 51 | + 'resolve' => RetourResolver::class.'::resolve', |
|
| 52 | 52 | 'description' => 'This query is used to query for Retour redirects.', |
| 53 | 53 | ], |
| 54 | 54 | 'retourRedirects' => [ |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'description' => 'The siteId to list all redirects for.' |
| 66 | 66 | ], |
| 67 | 67 | ], |
| 68 | - 'resolve' => RetourResolver::class . '::resolveAll', |
|
| 68 | + 'resolve' => RetourResolver::class.'::resolveAll', |
|
| 69 | 69 | 'description' => 'This query is used to query for all Retour redirects for a site.', |
| 70 | 70 | ], |
| 71 | 71 | ]; |
@@ -64,8 +64,8 @@ |
||
| 64 | 64 | if ($redirect === null && Craft::$app->getElements()->getElementByUri(trim($uri, '/'), $siteId) === null) { |
| 65 | 65 | // Set the `site` virtual field |
| 66 | 66 | $redirect['site'] = null; |
| 67 | - if (isset($redirect['siteId']) && (int)$redirect['siteId'] !== 0) { |
|
| 68 | - $site = Craft::$app->getSites()->getSiteById((int)$redirect['siteId']); |
|
| 67 | + if (isset($redirect['siteId']) && (int) $redirect['siteId'] !== 0) { |
|
| 68 | + $site = Craft::$app->getSites()->getSiteById((int) $redirect['siteId']); |
|
| 69 | 69 | if ($site !== null) { |
| 70 | 70 | $redirect['site'] = $site->handle; |
| 71 | 71 | } |
@@ -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", |
@@ -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'); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * @var bool|array |
| 70 | 70 | */ |
| 71 | - protected array|bool|int $allowAnonymous = [ |
|
| 71 | + protected array | bool | int $allowAnonymous = [ |
|
| 72 | 72 | ]; |
| 73 | 73 | |
| 74 | 74 | // Public Methods |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | ->orderBy([$sortField => $sortType]) |
| 125 | 125 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
| 126 | 126 | ->orFilterWhere(['like', 'referrerUrl', $filter]); |
| 127 | - if ((int)$siteId !== 0) { |
|
| 127 | + if ((int) $siteId !== 0) { |
|
| 128 | 128 | $query->andWhere(['siteId' => $siteId]); |
| 129 | 129 | } |
| 130 | 130 | if ($handled !== 'all') { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | foreach ($stats as &$stat) { |
| 137 | 137 | $stat['addLink'] = ''; |
| 138 | 138 | if (!$stat['handledByRetour']) { |
| 139 | - $encodedUrl = urlencode('/' . ltrim($stat['redirectSrcUrl'], '/')); |
|
| 139 | + $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); |
|
| 140 | 140 | // Add the siteId to the URL, but keep the current behavior of passing in siteId=0 for "all" |
| 141 | 141 | $statSiteId = $stat['siteId'] ?? 0; |
| 142 | 142 | try { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } catch (SiteNotFoundException $e) { |
| 145 | 145 | $primarySite = null; |
| 146 | 146 | } |
| 147 | - if ($primarySite !== null && $statSiteId == (int)$primarySite->id) { |
|
| 147 | + if ($primarySite !== null && $statSiteId == (int) $primarySite->id) { |
|
| 148 | 148 | $statSiteId = 0; |
| 149 | 149 | } |
| 150 | 150 | $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | ->orderBy([$sortField => $sortType]) |
| 221 | 221 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
| 222 | 222 | ->orFilterWhere(['like', 'redirectDestUrl', $filter]); |
| 223 | - if ((int)$siteId !== 0) { |
|
| 223 | + if ((int) $siteId !== 0) { |
|
| 224 | 224 | $query->andWhere(['siteId' => $siteId]); |
| 225 | 225 | } |
| 226 | 226 | if ($shortLinks) { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect['id']); |
|
| 263 | + $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); |
|
| 264 | 264 | } |
| 265 | 265 | // Format the data for the API |
| 266 | 266 | if ($redirects) { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $siteId = reset($variables['enabledSiteIds']); |
| 90 | 90 | } |
| 91 | 91 | } else { |
| 92 | - self::requirePermission('editSite:' . $siteId); |
|
| 92 | + self::requirePermission('editSite:'.$siteId); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } else { |
| 115 | 115 | $variables['sitesMenuLabel'] = Craft::t( |
| 116 | 116 | 'site', |
| 117 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
| 117 | + $sites->getSiteById((int) $variables['currentSiteId'])->name |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | 120 | } else { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | if ($siteHandle !== null) { |
| 138 | 138 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 139 | 139 | if (!$site) { |
| 140 | - throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 140 | + throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 141 | 141 | } |
| 142 | 142 | $siteId = $site->id; |
| 143 | 143 | } else { |