mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-57841 exporter: Allow scalars as related objects
This commit is contained in:
parent
e7059ec5e2
commit
13fb78a4f6
2 changed files with 23 additions and 4 deletions
6
lib/classes/external/exporter.php
vendored
6
lib/classes/external/exporter.php
vendored
|
@ -96,7 +96,11 @@ abstract class exporter {
|
|||
}
|
||||
|
||||
} else {
|
||||
if (array_key_exists($key, $related) && $related[$key] instanceof $classname) {
|
||||
$scalartypes = ['string', 'int', 'bool', 'float'];
|
||||
$scalarcheck = 'is_' . $classname;
|
||||
if (array_key_exists($key, $related) &&
|
||||
((in_array($classname, $scalartypes) && $scalarcheck($related[$key])) ||
|
||||
($related[$key] instanceof $classname))) {
|
||||
$this->related[$key] = $related[$key];
|
||||
} else {
|
||||
throw new coding_exception($missingdataerr . $key . ' => ' . $classname);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue