Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Preview link when no locale set #861

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Extension/FluentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1056,15 +1056,6 @@ public function LocaleInformation($locale = null)
$localeObj = Locale::getDefault();
}

if (!$localeObj) {
// There is no default locale, this can happen if no locales have been setup
// This will happen when doing integration unit testing, though can also happen during regular
// website operation
// This temporary Locale is created to prevent a invalid argument exception in
// RecordLocale::__construct()
$localeObj = Locale::create(['Locale' => i18n::get_locale()]);
}

return RecordLocale::create($this->owner, $localeObj);
}

Expand Down Expand Up @@ -1160,8 +1151,11 @@ public function updateFluentCMSField(FormField $field)
public function updatePreviewLink(&$link): void
{
$owner = $this->owner;
$info = $owner->LocaleInformation(FluentState::singleton()->getLocale());

$locale = FluentState::singleton()->getLocale();
if ($locale === null || $locale === '') {
return;
}
$info = $owner->LocaleInformation($locale);
if (!$info->getSourceLocale()) {
$link = null;
}
Expand Down
Loading