Commit 6b206c53 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-57273 persistent: Dont allow set and get for helpers

Helper methods (ie custom methods on a persistent) should not be callable via set() or get() even
if they start with set_ or get_. They are not the same as custom getters and setters for real persistent
properties.
parent 0ce135f6
......@@ -125,7 +125,7 @@ class competency_summary_exporter extends \core\external\exporter {
$result->scaleconfiguration = $scaleconfiguration;
$result->scaleid = $scaleid;
$level = $competency->get('level');
$level = $competency->get_level();
$taxonomy = $this->related['framework']->get_taxonomy($level);
$result->taxonomyterm = (string) (competency_framework::get_taxonomies_list()[$taxonomy]);
......
......@@ -78,7 +78,7 @@ class evidence_exporter extends \core\external\persistent_exporter {
$other['actionuser'] = $actionuser;
}
$other['description'] = $this->persistent->get('description');
$other['description'] = $this->persistent->get_description();
$other['userdate'] = userdate($this->persistent->get('timecreated'));
......
......@@ -112,6 +112,9 @@ abstract class persistent {
* @return $this
*/
final public function set($property, $value) {
if (!static::has_property($property)) {
throw new coding_exception('Unexpected property \'' . s($property) .'\' requested.');
}
$methodname = 'set_' . $property;
if (method_exists($this, $methodname)) {
$this->$methodname($value);
......@@ -133,6 +136,9 @@ abstract class persistent {
* @return mixed
*/
final public function get($property) {
if (!static::has_property($property)) {
throw new coding_exception('Unexpected property \'' . s($property) .'\' requested.');
}
$methodname = 'get_' . $property;
if (method_exists($this, $methodname)) {
return $this->$methodname();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment