MDL-46138 tasks: The adhoc task is being too helpful with json_encoding/decoding.

This commit is contained in:
Damyon Wiese
2014-07-11 09:45:27 +08:00
parent b4d0a4479c
commit f72a23d69b
2 changed files with 19 additions and 2 deletions
+17
View File
@@ -64,6 +64,14 @@ abstract class adhoc_task extends task_base {
$this->customdata = json_encode($customdata);
}
/**
* Alternate setter for $customdata. Expects the data as a json_encoded string.
* @param string json_encoded string
*/
public function set_custom_data_as_string($customdata) {
$this->customdata = $customdata;
}
/**
* Getter for $customdata.
* @return mixed (anything that can be handled by json_decode).
@@ -72,4 +80,13 @@ abstract class adhoc_task extends task_base {
return json_decode($this->customdata);
}
/**
* Alternate getter for $customdata.
* @return string (this is the raw json encoded version).
*/
public function get_custom_data_as_string() {
return $this->customdata;
}
}