Commit d5818626 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-57273 persistent: Improved style

Use \blah::class instead of '\\blah' in define_class functions.
Allow chaining of setters by returning $this.
parent 599acbe7
......@@ -38,7 +38,7 @@ use core_competency\external\performance_helper;
class user_evidence_summary_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\user_evidence';
return \core_competency\user_evidence::class;
}
protected static function define_other_properties() {
......
......@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
class competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\competency';
return \core_competency\competency::class;
}
protected static function define_related() {
......
......@@ -41,7 +41,7 @@ class competency_framework_exporter extends \core\external\persistent_exporter {
* @return string
*/
protected static function define_class() {
return 'core_competency\\competency_framework';
return \core_competency\competency_framework::class;
}
/**
......
......@@ -33,6 +33,6 @@ defined('MOODLE_INTERNAL') || die();
class course_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\course_competency';
return \core_competency\course_competency::class;
}
}
......@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
class course_competency_settings_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\course_competency_settings';
return \core_competency\course_competency_settings::class;
}
}
......@@ -33,6 +33,6 @@ defined('MOODLE_INTERNAL') || die();
class course_module_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\course_module_competency';
return \core_competency\course_module_competency::class;
}
}
......@@ -66,7 +66,7 @@ class evidence_exporter extends \core\external\persistent_exporter {
}
protected static function define_class() {
return 'core_competency\\evidence';
return evidence::class;
}
protected function get_other_values(renderer_base $output) {
......
......@@ -33,6 +33,6 @@ defined('MOODLE_INTERNAL') || die();
class plan_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\plan_competency';
return \core_competency\plan_competency::class;
}
}
......@@ -41,7 +41,7 @@ use core_user\external\user_summary_exporter;
class plan_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\plan';
return \core_competency\plan::class;
}
protected static function define_related() {
......
......@@ -33,6 +33,6 @@ defined('MOODLE_INTERNAL') || die();
class related_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\related_competency';
return \core_competency\related_competency::class;
}
}
......@@ -33,6 +33,6 @@ defined('MOODLE_INTERNAL') || die();
class template_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\template_competency';
return \core_competency\template_competency::class;
}
}
......@@ -38,7 +38,7 @@ use core_competency\template_cohort;
class template_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\template';
return \core_competency\template::class;
}
protected function get_other_values(renderer_base $output) {
......
......@@ -37,7 +37,7 @@ use stdClass;
class user_competency_course_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\user_competency_course';
return \core_competency\user_competency_course::class;
}
protected static function define_related() {
......
......@@ -41,7 +41,7 @@ use core_user\external\user_summary_exporter;
class user_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\user_competency';
return user_competency::class;
}
protected static function define_related() {
......
......@@ -37,7 +37,7 @@ use stdClass;
class user_competency_plan_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\user_competency_plan';
return \core_competency\user_competency_plan::class;
}
protected static function define_related() {
......
......@@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
class user_evidence_competency_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\user_evidence_competency';
return \core_competency\user_evidence_competency::class;
}
}
......@@ -39,7 +39,7 @@ use core_files\external\stored_file_exporter;
class user_evidence_exporter extends \core\external\persistent_exporter {
protected static function define_class() {
return 'core_competency\\user_evidence';
return \core_competency\user_evidence::class;
}
protected static function define_other_properties() {
......
......@@ -109,12 +109,13 @@ abstract class persistent {
* raw records from the DB.
*
* @param string $property The property name.
* @return mixed
* @return $this
*/
final public function set($property, $value) {
$methodname = 'set_' . $property;
if (method_exists($this, $methodname)) {
return $this->$methodname($value);
$this->$methodname($value);
return $this;
}
return $this->raw_set($property, $value);
}
......@@ -177,7 +178,7 @@ abstract class persistent {
*
* @param string $property The property name.
* @param mixed $value The value.
* @return mixed
* @return $this
*/
final protected function raw_set($property, $value) {
if (!static::has_property($property)) {
......@@ -188,6 +189,8 @@ abstract class persistent {
$this->validated = false;
}
$this->data[$property] = $value;
return $this;
}
/**
......
Markdown is supported
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