MDL-44403 events: bug fix in legacy event data for unknown_service_api_called
This commit is contained in:
@@ -34,16 +34,28 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class unknown_service_api_called extends \core\event\base {
|
||||
|
||||
/** Old data to be used for the legacy event. */
|
||||
protected $legacydata;
|
||||
|
||||
/**
|
||||
* Set method for legacy data.
|
||||
*
|
||||
* @param stdClass $data legacy event data.
|
||||
*/
|
||||
public function set_legacy_data($data) {
|
||||
$this->legacydata = $data;
|
||||
// This function is not used and will be removed in 2.7.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns custom data for event observers.
|
||||
*
|
||||
* @since 2.6.2
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function get_message_data() {
|
||||
if ($this->is_restored()) {
|
||||
throw new \coding_exception('Function get_message_data() can not be used on restored events.');
|
||||
}
|
||||
$data = (object)$this->eventdata['other'];
|
||||
$data->xml = new SimpleXMLElement($data->rawbody);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +101,6 @@ class unknown_service_api_called extends \core\event\base {
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->legacydata;
|
||||
return $this->get_message_data();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -147,8 +147,6 @@ switch ($messagetype) {
|
||||
//Fire an event if we get a web service request which we don't support directly.
|
||||
//This will allow others to extend the LTI services, which I expect to be a common
|
||||
//use case, at least until the spec matures.
|
||||
// Please note that you will have to change $eventdata['other']['body'] into an xml
|
||||
// element in an event observer as done above.
|
||||
$eventdata = array();
|
||||
$eventdata['other'] = array();
|
||||
$eventdata['other']['body'] = $rawbody;
|
||||
@@ -169,7 +167,6 @@ switch ($messagetype) {
|
||||
|
||||
try {
|
||||
$event = \mod_lti\event\unknown_service_api_called::create($eventdata);
|
||||
$event->set_legacy_data($eventdata);
|
||||
$event->trigger();
|
||||
} catch (Exception $e) {
|
||||
$lti_web_service_handled = false;
|
||||
|
||||
Reference in New Issue
Block a user