mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
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.
This commit is contained in:
parent
0ce135f65d
commit
6b206c5309
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user