Skip to content
Snippets Groups Projects
Commit c2b09a90 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

check if the I18NString is an object or just a string (happens when only one...

check if the I18NString is an object or just a string (happens when only one content language is defined), re #154
parent 45510fb9
No related branches found
No related tags found
No related merge requests found
......@@ -132,9 +132,9 @@ class AdvancedBasicDataWizardStep extends BasicDataWizardStep
$values[__CLASS__] = array_merge($values[__CLASS__], [
'subtitle' => $course->untertitel,
'subtitle_i18n' => $course->untertitel->toArray(),
'subtitle_i18n' => is_object($course->untertitel) ? $course->untertitel->toArray() : $course->untertitel,
'kind' => $course->art,
'kind_i18n' => $course->art->toArray(),
'kind_i18n' => is_object($course->art) ? $course->art->toArray() : $course->art,
'ects' => $course->ects,
'maxmembers' => $course->admission_turnout,
]);
......
......@@ -491,11 +491,12 @@ class BasicDataWizardStep implements CourseWizardStep
'coursetype' => $course->status,
'start_time' => $course->start_time,
'name' => $course->name,
'name_i18n' => $course->name->toArray(),
'name_i18n' => is_object($course->name) ? $course->name->toArray() : $course->name,
'number' => $course->veranstaltungsnummer,
'institute' => $course->institut_id,
'description' => $course->beschreibung,
'description_i18n' => $course->beschreibung->toArray()
'description_i18n' => is_object($course->beschreibung) ?
$course->beschreibung->toArray() : $course->beschreibung
];
$lecturers = $course->members->findBy('status', 'dozent')->pluck('user_id');
$data['lecturers'] = array_flip($lecturers);
......@@ -584,26 +585,31 @@ class BasicDataWizardStep implements CourseWizardStep
*/
protected function makeI18N($values, $indices)
{
/**
* Create array for configured content languages
*/
$translations = array_combine(
array_keys($GLOBALS['CONTENT_LANGUAGES']),
array_fill(0, count($GLOBALS['CONTENT_LANGUAGES']), '')
);
// We only need to do something if there are several content languages.
if (count($GLOBALS['CONTENT_LANGUAGES']) > 1) {
/**
* Create array for configured content languages
*/
$translations = array_combine(
array_keys($GLOBALS['CONTENT_LANGUAGES']),
array_fill(0, count($GLOBALS['CONTENT_LANGUAGES']), '')
);
foreach ($indices as $index) {
// There are values given => create an I18NString
if ($values[$index]) {
foreach ($indices as $index) {
// There are values given => create an I18NString
if ($values[$index]) {
$values[$index] = new I18NString($values[$index], $values[$index . '_i18n']);
$values[$index] = new I18NString($values[$index], $values[$index . '_i18n']);
// Current index is not set (yet), create an empty I18NString
} else {
// Current index is not set (yet), create an empty I18NString
} else {
$values[$index] = new I18NString('', $translations);
$values[$index] = new I18NString('', $translations);
}
}
}
return $values;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment