Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 6, 2024
1 parent 2714bff commit b14687a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Extension/FluentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TractorCow\Fluent\Extension;

use LogicException;
use SilverStripe\i18n\i18n;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
Expand Down Expand Up @@ -1055,12 +1056,13 @@ public function LocaleInformation($locale = null)
$localeObj = Locale::getDefault();
}

if (!$locale && !$localeObj) {
// There is no default locale, this can happen when if fluent is installed though 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(['Title' => 'Temp locale']);
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

0 comments on commit b14687a

Please sign in to comment.