MDL-49361 lang: Add support for $CFG->customstringmanager
authorDavid Mudrák <david@moodle.com>
Thu, 12 Mar 2015 20:03:43 +0000 (21:03 +0100)
committerDavid Mudrák <david@moodle.com>
Fri, 13 Mar 2015 09:45:10 +0000 (10:45 +0100)
lib/moodlelib.php
lib/upgrade.txt

index 7d8ea2f..675ba26 100644 (file)
@@ -6842,6 +6842,26 @@ function get_string_manager($forcereload=false) {
                 $translist = explode(',', $CFG->langlist);
             }
 
+            if (!empty($CFG->config_php_settings['customstringmanager'])) {
+                $classname = $CFG->config_php_settings['customstringmanager'];
+
+                if (class_exists($classname)) {
+                    $implements = class_implements($classname);
+
+                    if (isset($implements['core_string_manager'])) {
+                        $singleton = new $classname($CFG->langotherroot, $CFG->langlocalroot, $translist);
+                        return $singleton;
+
+                    } else {
+                        debugging('Unable to instantiate custom string manager: class '.$classname.
+                            ' does not implement the core_string_manager interface.');
+                    }
+
+                } else {
+                    debugging('Unable to instantiate custom string manager: class '.$classname.' can not be found.');
+                }
+            }
+
             $singleton = new core_string_manager_standard($CFG->langotherroot, $CFG->langlocalroot, $translist);
 
         } else {
index 06b25b0..4cf6f2f 100644 (file)
@@ -24,6 +24,8 @@ information provided here is intended especially for developers.
   and sql_reader which use iterators to be more memory efficient.
 * $CFG->enabletgzbackups setting has been removed as now backups are stored internally using .tar.gz format by default, you can
   set $CFG->usezipbackups to store them in zip format. This does not affect the restore process, which continues accepting both.
+* Added support for custom string manager implementations via $CFG->customstringmanager
+  directive in the config.php. See MDL-49361 for details.
 
 === 2.8 ===