MDL-43635: Further support custom contexts: reading from config DB table and reset method for after plugin install

Add PHPUnit test for custom context changes
This commit is contained in:
Brent Boghosian
2014-03-03 12:03:09 -05:00
parent 0e088aec08
commit e7fa4cde7b
2 changed files with 155 additions and 1 deletions
+17 -1
View File
@@ -5779,6 +5779,13 @@ class context_helper extends context {
protected function __construct() {
}
/**
* Reset internal context levels array.
*/
public static function reset_levels() {
self::$alllevels = null;
}
/**
* Initialise context levels, call before using self::$alllevels.
*/
@@ -5801,8 +5808,17 @@ class context_helper extends context {
return;
}
$levels = $CFG->custom_context_classes;
if (!is_array($levels)) {
$levels = @unserialize($levels);
}
if (!is_array($levels)) {
debugging('Invalid $CFG->custom_context_classes detected, value ignored.', DEBUG_DEVELOPER);
return;
}
// Unsupported custom levels, use with care!!!
foreach ($CFG->custom_context_classes as $level => $classname) {
foreach ($levels as $level => $classname) {
self::$alllevels[$level] = $classname;
}
ksort(self::$alllevels);