diff --git a/lib/classes/SimpleORMap.php b/lib/classes/SimpleORMap.php index f3993c2706e971e11f6d7fec511f99e52f92b121..d8cdb8eca06affeee1b7d21acda18fe994c1be11 100644 --- a/lib/classes/SimpleORMap.php +++ b/lib/classes/SimpleORMap.php @@ -84,6 +84,11 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate */ protected static $performs_batch_operation = false; + /** + * Defines which variant of the I18NString class should be used + */ + protected string $i18n_class = I18NString::class; + /** * name of db table * @return string @@ -2232,7 +2237,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate $field = strtolower($field); if ($this->content[$field] === null || $this->content_db[$field] === null) { return $this->content[$field] !== $this->content_db[$field]; - } else if ($this->content[$field] instanceof I18NString || $this->content_db[$field] instanceof I18NString) { + } else if ( + $this->content[$field] instanceof I18NString + || $this->content_db[$field] instanceof I18NString + ) { // Trigger loading of translations if ($this->content[$field] instanceof I18NString) { $this->content[$field]->toArray(); @@ -2512,7 +2520,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate $value->setMetadata($meta); $this->content[$field] = $value; } else { - $this->content[$field] = new I18NString($value, null, $meta); + $this->content[$field] = new $this->i18n_class($value, null, $meta); } return $this->content[$field]; } diff --git a/lib/models/DatafieldEntryModelI18N.php b/lib/models/DatafieldEntryModelI18N.php index aa93a638e66ab502bbeff3c0d1c861b90ca26a8a..19974111a091a2c053f437f08a1a36857c58af00 100644 --- a/lib/models/DatafieldEntryModelI18N.php +++ b/lib/models/DatafieldEntryModelI18N.php @@ -28,6 +28,8 @@ class DatafieldEntryModelI18N extends DatafieldEntryModel { + protected string $i18n_class = I18NStringDatafield::class; + protected static function configure($config = []) { $config['i18n_fields']['content'] = true;