diff --git a/lib/models/DatafieldEntryModelI18N.class.php b/lib/models/DatafieldEntryModelI18N.class.php index bea234df067bcea3a19e3a58a85c3e5094b348a1..810b3f84c1864a1c6c0765c8e0f2ca223555418a 100644 --- a/lib/models/DatafieldEntryModelI18N.class.php +++ b/lib/models/DatafieldEntryModelI18N.class.php @@ -27,6 +27,8 @@ class DatafieldEntryModelI18N extends DatafieldEntryModel { + protected string $i18n_class = I18NStringDatafield::class; + protected static function configure($config = []) { $config['i18n_fields']['content'] = true; diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 0ecb9712ac3f0b6bdf153321c4b645e677f54d0c..03a4f77105730ff347fc464e92530d1605945688 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.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 @@ -2248,7 +2253,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(); @@ -2528,7 +2536,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]; }