Skip to content

Commit 5ca8eb0

Browse files
authored
Merge pull request #141 from catalyst/moodle-45-compatibility
Add Moodle 4.5 support
2 parents e619a01 + 100dd4e commit 5ca8eb0

File tree

6 files changed

+82
-6
lines changed

6 files changed

+82
-6
lines changed

classes/hook_callbacks.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
// This file is part of Moodle - https://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
16+
17+
namespace mod_cms;
18+
19+
/**
20+
* Hook callbacks for tool_redirects.
21+
*
22+
* @package mod_cms
23+
* @author Alexander Van der Bellen <[email protected]>
24+
* @copyright 2024 Catalyst IT Australia
25+
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26+
*/
27+
class hook_callbacks {
28+
29+
/**
30+
* Listener for the after_config hook.
31+
*
32+
* @param \core\hook\after_config $hook
33+
*/
34+
public static function after_config(\core\hook\after_config $hook): void {
35+
global $CFG;
36+
37+
require_once($CFG->dirroot . '/vendor/autoload.php');
38+
}
39+
}

classes/local/datasource/restore/fields.php

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class fields {
3232
/** @var \restore_cms_activity_structure_step The stepslib controlling this process. */
3333
protected $stepslib;
3434

35+
/** @var array Components array */
36+
protected $components = [];
37+
3538
/**
3639
* Constructs the processor.
3740
*

db/hooks.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Hook callbacks.
19+
*
20+
* @package mod_cms
21+
* @author Alexander Van der Bellen <[email protected]>
22+
* @copyright 2024 Catalyst IT Australia
23+
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
defined('MOODLE_INTERNAL') || die();
27+
28+
$callbacks = [
29+
[
30+
'hook' => \core\hook\after_config::class,
31+
'callback' => '\mod_cms\hook_callbacks::after_config',
32+
],
33+
];

tests/datasource_site_test.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ public function test_get_data() {
6262
$ds = new dssite($cms);
6363
$data = $ds->get_data();
6464

65-
$this->assertObjectHasAttribute('fullname', $data);
66-
$this->assertObjectHasAttribute('shortname', $data);
67-
$this->assertObjectHasAttribute('wwwroot', $data);
65+
// Some versions of PHPUnit do not have assertObjectHasProperty(), and assertObjectHasAttribute() is deprecated.
66+
$this->assertTrue(property_exists($data, 'fullname'));
67+
$this->assertTrue(property_exists($data, 'shortname'));
68+
$this->assertTrue(property_exists($data, 'wwwroot'));
6869
}
6970

7071
/**

tests/renderer_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function test_get_data() {
6767
foreach (dsbase::BUILTIN_DATASOURCES as $ds) {
6868
$classname = 'mod_cms\\local\\datasource\\' . $ds;
6969
$attribute = $classname::get_shortname();
70-
$this->assertObjectHasAttribute($attribute, $data);
70+
$this->assertTrue(property_exists($data, $attribute));
7171
$this->assertIsObject($data->$attribute);
7272
}
7373
}

version.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
defined('MOODLE_INTERNAL') || die();
2727

28-
$plugin->version = 2024090305;
28+
$plugin->version = 2024090306;
2929
$plugin->requires = 2022112800; // Moodle 4.1 and above.
30-
$plugin->supported = [401, 401]; // Moodle 4.1.
30+
$plugin->supported = [401, 405]; // Moodle 4.1.
3131
$plugin->component = 'mod_cms';
3232
$plugin->maturity = MATURITY_STABLE;
3333
$plugin->release = 2023051800;

0 commit comments

Comments
 (0)