Skip to content

Commit

Permalink
FIX Preview link when no locale set
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 10, 2024
1 parent 87abf4c commit d5183c4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Extension/FluentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class FluentExtension extends DataExtension
*/
const INHERITANCE_MODE_ANY = 'any';

/**
* Title of a temporary locale used when once hasn't yet been created
*/
private const TEMP_LOCALE_TITLE = 'Temp locale';

/**
* DB fields to be used added in when creating a localised version of the owner's table
*
Expand Down Expand Up @@ -1062,7 +1067,10 @@ public function LocaleInformation($locale = null)
// website operation
// This temporary Locale is created to prevent a invalid argument exception in
// RecordLocale::__construct()
$localeObj = Locale::create(['Locale' => i18n::get_locale()]);
$localeObj = Locale::create([
'Title' => FluentExtension::TEMP_LOCALE_TITLE,
'Locale' => i18n::get_locale()
]);
}

return RecordLocale::create($this->owner, $localeObj);
Expand Down Expand Up @@ -1161,7 +1169,9 @@ public function updatePreviewLink(&$link): void
{
$owner = $this->owner;
$info = $owner->LocaleInformation(FluentState::singleton()->getLocale());

if ($info->Title === FluentExtension::TEMP_LOCALE_TITLE) {
return;
}
if (!$info->getSourceLocale()) {
$link = null;
}
Expand Down

0 comments on commit d5183c4

Please sign in to comment.