MDL-72163 admin: Create interface for settings with a url

This commit is contained in:
Andrew Nicols
2021-07-16 13:48:18 +08:00
parent 78c96c6f44
commit d55aeee10c
4 changed files with 78 additions and 25 deletions

View File

@@ -102,6 +102,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_admin\local\settings\linkable_settings_page;
defined('MOODLE_INTERNAL') || die();
/// Add libraries
@@ -769,7 +771,7 @@ interface parentable_part_of_admin_tree extends part_of_admin_tree {
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_category implements parentable_part_of_admin_tree {
class admin_category implements parentable_part_of_admin_tree, linkable_settings_page {
/** @var part_of_admin_tree[] An array of part_of_admin_tree objects that are this object's children */
protected $children;
@@ -811,7 +813,7 @@ class admin_category implements parentable_part_of_admin_tree {
}
/**
* Get the URL to view this page.
* Get the URL to view this settings page.
*
* @return moodle_url
*/
@@ -1205,7 +1207,7 @@ class admin_root extends admin_category {
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_externalpage implements part_of_admin_tree {
class admin_externalpage implements part_of_admin_tree, linkable_settings_page {
/** @var string An internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects */
public $name;
@@ -1255,6 +1257,15 @@ class admin_externalpage implements part_of_admin_tree {
$this->context = $context;
}
/**
* Get the URL to view this settings page.
*
* @return moodle_url
*/
public function get_settings_page_url(): moodle_url {
return new moodle_url($this->url);
}
/**
* Returns a reference to the part_of_admin_tree object with internal name $name.
*
@@ -1426,7 +1437,7 @@ class admin_settingdependency {
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_settingpage implements part_of_admin_tree {
class admin_settingpage implements part_of_admin_tree, linkable_settings_page {
/** @var string An internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects */
public $name;
@@ -1478,6 +1489,20 @@ class admin_settingpage implements part_of_admin_tree {
$this->context = $context;
}
/**
* Get the URL to view this page.
*
* @return moodle_url
*/
public function get_settings_page_url(): moodle_url {
return new moodle_url(
'/admin/settings.php',
[
'section' => $this->name,
]
);
}
/**
* see admin_category
*