MDL-72125 testing: Make global $CFG available when including generators

This will remove the requirement to add the global $CFG call to the top
of generator scripts.
This commit is contained in:
Andrew Nicols 2021-07-19 16:42:21 +08:00
parent 753035e090
commit 1a885a1756

View file

@ -103,6 +103,9 @@ EOD;
* @return component_generator_base or rather an instance of the appropriate subclass. * @return component_generator_base or rather an instance of the appropriate subclass.
*/ */
public function get_plugin_generator($component) { public function get_plugin_generator($component) {
// Note: This global is included so that generator have access to it.
// CFG is widely used in require statements.
global $CFG;
list($type, $plugin) = core_component::normalize_component($component); list($type, $plugin) = core_component::normalize_component($component);
$cleancomponent = $type . '_' . $plugin; $cleancomponent = $type . '_' . $plugin;
if ($cleancomponent != $component) { if ($cleancomponent != $component) {