Merge branch 'MDL-70066-master' of git://github.com/lameze/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 5 Nov 2020 02:00:33 +0000 (10:00 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 5 Nov 2020 02:00:33 +0000 (10:00 +0800)
badges/classes/external/assertion_exporter.php
badges/classes/external/badgeclass_exporter.php

index 4e1e393..06b5238 100644 (file)
@@ -104,16 +104,16 @@ class assertion_exporter extends exporter {
         global $DB;
         $result = [];
 
-        if (array_key_exists('related_badge', $this->data)) {
-            $exporter = new badgeclass_exporter($this->data['related_badge'], $this->related);
+        if (property_exists($this->data, 'related_badge')) {
+            $exporter = new badgeclass_exporter($this->data->related_badge, $this->related);
             $result['badge'] = $exporter->export($output);
         }
-        if (array_key_exists('related_recipient', $this->data)) {
-            $exporter = new recipient_exporter($this->data['related_recipient'], $this->related);
+        if (property_exists($this->data, 'related_recipient')) {
+            $exporter = new recipient_exporter($this->data->related_recipient, $this->related);
             $result['recipient'] = $exporter->export($output);
         }
-        if (array_key_exists('related_verify', $this->data)) {
-            $exporter = new verification_exporter($this->data['related_verify'], $this->related);
+        if (property_exists($this->data, 'related_verify')) {
+            $exporter = new verification_exporter($this->data->related_verify, $this->related);
             $result['verification'] = $exporter->export($output);
         }
         return $result;
index f16d762..4d4880f 100644 (file)
@@ -54,28 +54,28 @@ class badgeclass_exporter extends exporter {
                 $isarray = true;
             }
             $prefixed = 'related_' . $one;
-            if (array_key_exists($one, $data) && !array_key_exists($one, $related)) {
+            if (property_exists($data, $one) && !array_key_exists($one, $related)) {
                 if ($isarray) {
                     $newrelated = [];
-                    foreach ($data[$one] as $item) {
+                    foreach ($data->$one as $item) {
                         $newrelated[] = (object) $item;
                     }
                     $related[$one] = $newrelated;
                 } else {
-                    $related[$one] = (object) $data[$one];
+                    $related[$one] = (object) $data->$one;
                 }
-                unset($data[$one]);
-            } else if (array_key_exists($prefixed, $data) && !array_key_exists($one, $related)) {
+                unset($data->$one);
+            } else if (property_exists($data, $prefixed) && !array_key_exists($one, $related)) {
                 if ($isarray) {
                     $newrelated = [];
-                    foreach ($data[$prefixed] as $item) {
+                    foreach ($data->$prefixed as $item) {
                         $newrelated[] = (object) $item;
                     }
                     $related[$one] = $newrelated;
                 } else {
-                    $related[$one] = (object) $data[$prefixed];
+                    $related[$one] = (object) $data->$prefixed;
                 }
-                unset($data[$prefixed]);
+                unset($data->$prefixed);
             } else if (!array_key_exists($one, $related)) {
                 $related[$one] = null;
             }