diff --git a/classes/hook_callbacks.php b/classes/hook_callbacks.php new file mode 100644 index 0000000..ade4ca5 --- /dev/null +++ b/classes/hook_callbacks.php @@ -0,0 +1,39 @@ +. + +namespace mod_cms; + +/** + * Hook callbacks for tool_redirects. + * + * @package mod_cms + * @author Alexander Van der Bellen + * @copyright 2024 Catalyst IT Australia + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class hook_callbacks { + + /** + * Listener for the after_config hook. + * + * @param \core\hook\after_config $hook + */ + public static function after_config(\core\hook\after_config $hook): void { + global $CFG; + + require_once($CFG->dirroot . '/vendor/autoload.php'); + } +} diff --git a/classes/local/datasource/restore/fields.php b/classes/local/datasource/restore/fields.php index de7f986..7bea0ec 100644 --- a/classes/local/datasource/restore/fields.php +++ b/classes/local/datasource/restore/fields.php @@ -32,6 +32,9 @@ class fields { /** @var \restore_cms_activity_structure_step The stepslib controlling this process. */ protected $stepslib; + /** @var array Components array */ + protected $components = []; + /** * Constructs the processor. * diff --git a/db/hooks.php b/db/hooks.php new file mode 100644 index 0000000..617aac2 --- /dev/null +++ b/db/hooks.php @@ -0,0 +1,33 @@ +. + +/** + * Hook callbacks. + * + * @package mod_cms + * @author Alexander Van der Bellen + * @copyright 2024 Catalyst IT Australia + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$callbacks = [ + [ + 'hook' => \core\hook\after_config::class, + 'callback' => '\mod_cms\hook_callbacks::after_config', + ], +]; diff --git a/tests/datasource_site_test.php b/tests/datasource_site_test.php index 62036b7..915a743 100644 --- a/tests/datasource_site_test.php +++ b/tests/datasource_site_test.php @@ -62,9 +62,10 @@ public function test_get_data() { $ds = new dssite($cms); $data = $ds->get_data(); - $this->assertObjectHasAttribute('fullname', $data); - $this->assertObjectHasAttribute('shortname', $data); - $this->assertObjectHasAttribute('wwwroot', $data); + // Some versions of PHPUnit do not have assertObjectHasProperty(), and assertObjectHasAttribute() is deprecated. + $this->assertTrue(property_exists($data, 'fullname')); + $this->assertTrue(property_exists($data, 'shortname')); + $this->assertTrue(property_exists($data, 'wwwroot')); } /** diff --git a/tests/renderer_test.php b/tests/renderer_test.php index 426ae0d..e224e46 100644 --- a/tests/renderer_test.php +++ b/tests/renderer_test.php @@ -67,7 +67,7 @@ public function test_get_data() { foreach (dsbase::BUILTIN_DATASOURCES as $ds) { $classname = 'mod_cms\\local\\datasource\\' . $ds; $attribute = $classname::get_shortname(); - $this->assertObjectHasAttribute($attribute, $data); + $this->assertTrue(property_exists($data, $attribute)); $this->assertIsObject($data->$attribute); } } diff --git a/version.php b/version.php index 9f811c3..50abf48 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024090305; +$plugin->version = 2024090306; $plugin->requires = 2022112800; // Moodle 4.1 and above. -$plugin->supported = [401, 401]; // Moodle 4.1. +$plugin->supported = [401, 405]; // Moodle 4.1. $plugin->component = 'mod_cms'; $plugin->maturity = MATURITY_STABLE; $plugin->release = 2023051800;