mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-21694 usin new core_subsystesm() in renderers too; adding more docs
This commit is contained in:
parent
d24016944f
commit
6d16792cf2
@ -6821,14 +6821,20 @@ function normalize_component($component) {
|
||||
|
||||
/**
|
||||
* List all core subsystems, this is especially useful for get_string()
|
||||
* and output renderers. The relative location is not always included.
|
||||
* and output renderers.
|
||||
*
|
||||
* The location is dirroot relative path, NULL means there is no special
|
||||
* directory for this subsystem.
|
||||
*
|
||||
* Unfortunately no module may be named like any core subsystem because
|
||||
* we are still lazy to use proper "mod_" prefix in get_string() and elsewhere.
|
||||
*
|
||||
* @return array of strings - name=>location
|
||||
*/
|
||||
function get_core_subsystems() {
|
||||
global $CFG;
|
||||
|
||||
static $info = null;
|
||||
static $info = null;
|
||||
|
||||
if (!$info) {
|
||||
$info = array(
|
||||
|
@ -106,9 +106,6 @@ abstract class renderer_factory_base implements renderer_factory {
|
||||
/** @var theme_config the theme we belong to. */
|
||||
protected $theme;
|
||||
|
||||
/** @var hardcoded list of core subtypes and their locations, add more if ßneeded */
|
||||
protected $core_subtypes = array('webservice' => 'webservice');
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param theme_config $theme the theme we belong to.
|
||||
@ -176,10 +173,11 @@ abstract class renderer_factory_base implements renderer_factory {
|
||||
}
|
||||
|
||||
} else if (!empty($subtype)) {
|
||||
if (!isset($this->core_subtypes[$subtype])) {
|
||||
$coresubsystems = get_core_subsystems();
|
||||
if (!isset($coresubsystems[$subtype])) {
|
||||
throw new coding_exception('Invalid core subtype "' . $subtype . '" in renderer request');
|
||||
}
|
||||
$rendererfile = $CFG->dirroot . '/' . $this->core_subtypes[$subtype] . '/renderer.php';
|
||||
$rendererfile = $CFG->dirroot . '/' . $coresubsystems[$subtype] . '/renderer.php';
|
||||
if (file_exists($rendererfile)) {
|
||||
include_once($rendererfile);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user