aboutsummaryrefslogtreecommitdiff
path: root/lib/models/SimpleORMap.class.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-11-20 16:23:59 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-11-21 08:38:19 +0100
commit3a214c3cffd8228e1a5d6a068059cf0c5fd29c10 (patch)
tree2a332c3bd8b739835ff0d8920c3f2326e0d09f4f /lib/models/SimpleORMap.class.php
parentf5be9a8831103aa8d9e9a5538cffb9400e40f382 (diff)
allow sorm to use other variants of I18NString, fixes #4891
Closes #4891 Merge request studip/studip!3664
Diffstat (limited to 'lib/models/SimpleORMap.class.php')
-rw-r--r--lib/models/SimpleORMap.class.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php
index bb2b5a6..de639b7 100644
--- a/lib/models/SimpleORMap.class.php
+++ b/lib/models/SimpleORMap.class.php
@@ -85,6 +85,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
*/
@@ -2253,7 +2258,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();
@@ -2533,7 +2541,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];
}