forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-80099_main' of https://github.com/marxjohnson/moodle
- Loading branch information
Showing
26 changed files
with
853 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/tests/fixtures/fakeplugins/hooktest/classes/callbacks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?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/>. | ||
namespace fake_hooktest; | ||
|
||
/** | ||
* Class callback container for fake_hooktest | ||
* | ||
* @package core | ||
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net} | ||
* @author Mark Johnson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class callbacks { | ||
/** | ||
* Test callback that is not replaced by a hook. | ||
* | ||
* @return string | ||
*/ | ||
public static function current_class_callback(): string { | ||
return 'Called current class callback'; | ||
} | ||
|
||
/** | ||
* Test callback that is replaced by a hook. | ||
* | ||
* @return string | ||
*/ | ||
public static function old_class_callback(): string { | ||
return 'Called deprecated class callback'; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
lib/tests/fixtures/fakeplugins/hooktest/classes/hook/hook_replacing_callback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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 fake_hooktest\hook; | ||
|
||
/** | ||
* Fixture for testing of hooks. | ||
* | ||
* @package core | ||
* @author Mark Johnson <[email protected]> | ||
* @copyright 2024 Catalyst IT Europe Ltd. | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
final class hook_replacing_callback implements | ||
\core\hook\described_hook, | ||
\core\hook\deprecated_callback_replacement { | ||
|
||
/** | ||
* Hook description. | ||
*/ | ||
public static function get_hook_description(): string { | ||
return 'Test hook replacing a plugin callback function.'; | ||
} | ||
|
||
/** | ||
* Deprecation info. | ||
*/ | ||
public static function get_deprecated_plugin_callbacks(): array { | ||
return ['old_callback']; | ||
} | ||
|
||
/** | ||
* List of tags that describe this hook. | ||
* | ||
* @return string[] | ||
*/ | ||
public static function get_hook_tags(): array { | ||
return ['test']; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
lib/tests/fixtures/fakeplugins/hooktest/classes/hook/hook_replacing_class_callback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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 fake_hooktest\hook; | ||
|
||
use core\attribute; | ||
|
||
/** | ||
* Fixture for testing of hooks. | ||
* | ||
* @package core | ||
* @author Mark Johnson <[email protected]> | ||
* @copyright 2024 Catalyst IT Europe Ltd. | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
#[attribute\label('Test hook replacing a class callback.')] | ||
#[attribute\tags('test')] | ||
#[attribute\hook\replaces_callbacks('callbacks::old_class_callback')] | ||
final class hook_replacing_class_callback { | ||
} |
44 changes: 44 additions & 0 deletions
44
lib/tests/fixtures/fakeplugins/hooktest/classes/hook_callbacks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?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/>. | ||
namespace fake_hooktest; | ||
|
||
/** | ||
* Hook callbacks | ||
* | ||
* @package core | ||
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net} | ||
* @author Mark Johnson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class hook_callbacks { | ||
/** | ||
* Test callback which replaces a plugin callback. | ||
* | ||
* @return string | ||
*/ | ||
public function component_callback_replacement(): string { | ||
return 'Called component callback replacement'; | ||
} | ||
|
||
/** | ||
* Test callback which replaced a plugin class callback. | ||
* | ||
* @return string | ||
*/ | ||
public function component_class_callback_replacement(): string { | ||
return 'Called component class callback replacement'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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/>. | ||
namespace fake_hooktest; | ||
|
||
/** | ||
* Hook discovery for fake plugin. | ||
* | ||
* @package core | ||
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net} | ||
* @author Mark Johnson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class hooks implements \core\hook\discovery_agent { | ||
public static function discover_hooks(): array { | ||
return [ | ||
'fake_hooktest\hook\hook_replacing_callback' => [ | ||
'class' => 'fake_hooktest\hook\hook_replacing_callback', | ||
'description' => 'Hook replacing callback', | ||
'tags' => ['test'], | ||
], | ||
'fake_hooktest\hook\hook_replacing_class_callback' => [ | ||
'class' => 'fake_hooktest\hook\hook_replacing_class_callback', | ||
'description' => 'Hook replacing class callback', | ||
'tags' => ['test'], | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.