From 1d041d52a37cf4d2820965e741d7291f155f319f Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Fri, 14 Oct 2022 11:56:15 +0000
Subject: [PATCH] implement JsonSerializable for I18NString, fixes #1672

Closes #1672

Merge request studip/studip!1076
---
 lib/classes/I18NString.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/classes/I18NString.php b/lib/classes/I18NString.php
index 4dc61560454..aebe1c8d42c 100644
--- a/lib/classes/I18NString.php
+++ b/lib/classes/I18NString.php
@@ -3,9 +3,8 @@
 /**
  * I18NString class
  */
-class I18NString
+class I18NString implements JsonSerializable
 {
-
     /**
      * Text in default content language.
      *
@@ -77,6 +76,16 @@ class I18NString
         return (string) $this->base;
     }
 
+    /**
+     * Return the JSON representation of this i18n field in selected language.
+     *
+     * @return string
+     */
+    public function jsonSerialize()
+    {
+        return (string) $this;
+    }
+
     /**
      * Sets the language the content is translated into.
      *
-- 
GitLab