Upgrade to 4.0.0

This commit is contained in:
Bastian Allgeier
2023-11-28 09:33:56 +01:00
parent f96b96af76
commit 3b0b6546ca
480 changed files with 21371 additions and 13327 deletions

View File

@@ -8,9 +8,6 @@ class LanguageRoutes
{
/**
* Creates all multi-language routes
*
* @param \Kirby\Cms\App $kirby
* @return array
*/
public static function create(App $kirby): array
{
@@ -58,9 +55,6 @@ class LanguageRoutes
/**
* Create the fallback route
* for unprefixed default language URLs.
*
* @param \Kirby\Cms\App $kirby
* @return array
*/
public static function fallback(App $kirby): array
{
@@ -73,7 +67,10 @@ class LanguageRoutes
$extension = F::extension($path);
// try to redirect prefixed pages
if (empty($extension) === true && $page = $kirby->page($path)) {
if (
empty($extension) === true &&
$page = $kirby->page($path)
) {
$url = $kirby->request()->url([
'query' => null,
'params' => null,
@@ -81,15 +78,17 @@ class LanguageRoutes
]);
if ($url->toString() !== $page->url()) {
// redirect to translated page directly
// if translation is exists and languages detect is enabled
// redirect to translated page directly if translation
// is exists and languages detect is enabled
$lang = $kirby->detectedLanguage()->code();
if (
$kirby->option('languages.detect') === true &&
$page->translation($kirby->detectedLanguage()->code())->exists() === true
$page->translation($lang)->exists() === true
) {
return $kirby
->response()
->redirect($page->url($kirby->detectedLanguage()->code()));
->redirect($page->url($lang));
}
return $kirby
@@ -105,9 +104,6 @@ class LanguageRoutes
/**
* Create the multi-language home page route
*
* @param \Kirby\Cms\App $kirby
* @return array
*/
public static function home(App $kirby): array
{
@@ -118,7 +114,10 @@ class LanguageRoutes
'env' => 'site',
'action' => function () use ($kirby) {
// find all languages with the same base url as the current installation
$languages = $kirby->languages()->filter('baseurl', $kirby->url());
$languages = $kirby->languages()->filter(
'baseurl',
$kirby->url()
);
// if there's no language with a matching base url,
// redirect to the default language
@@ -128,7 +127,8 @@ class LanguageRoutes
->redirect($kirby->defaultLanguage()->url());
}
// if there's just one language, we take that to render the home page
// if there's just one language,
// we take that to render the home page
if ($languages->count() === 1) {
$currentLanguage = $languages->first();
} else {