Skip to content

Commit

Permalink
Merge pull request #141 from catalyst/moodle-45-compatibility
Browse files Browse the repository at this point in the history
Add Moodle 4.5 support
  • Loading branch information
dmitriim authored Dec 10, 2024
2 parents e619a01 + 100dd4e commit 5ca8eb0
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 6 deletions.
39 changes: 39 additions & 0 deletions classes/hook_callbacks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

namespace mod_cms;

/**
* Hook callbacks for tool_redirects.
*
* @package mod_cms
* @author Alexander Van der Bellen <[email protected]>
* @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');
}
}
3 changes: 3 additions & 0 deletions classes/local/datasource/restore/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
33 changes: 33 additions & 0 deletions db/hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Hook callbacks.
*
* @package mod_cms
* @author Alexander Van der Bellen <[email protected]>
* @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',
],
];
7 changes: 4 additions & 3 deletions tests/datasource_site_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/renderer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5ca8eb0

Please sign in to comment.