Skip to content

Commit

Permalink
Merge pull request #861 from creative-commoners/pulls/7/fix-preview
Browse files Browse the repository at this point in the history
FIX Preview link when no locale set
  • Loading branch information
GuySartorelli authored Jun 11, 2024
2 parents 87abf4c + 201826e commit 80293d2
Showing 1 changed file with 5 additions and 11 deletions.
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

0 comments on commit 80293d2

Please sign in to comment.