summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/utils/ResourceLoader.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/utils/ResourceLoader.php')
-rw-r--r--www/wiki/extensions/Translate/utils/ResourceLoader.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/www/wiki/extensions/Translate/utils/ResourceLoader.php b/www/wiki/extensions/Translate/utils/ResourceLoader.php
new file mode 100644
index 00000000..1a8e5c29
--- /dev/null
+++ b/www/wiki/extensions/Translate/utils/ResourceLoader.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Stuff for handling configuration files in PHP format.
+ * @file
+ * @author Niklas Laxström
+ * @copyright Copyright © 2010 Niklas Laxström
+ * @license GPL-2.0-or-later
+ */
+
+/**
+ * Stuff for handling configuration files in PHP format.
+ */
+class PHPVariableLoader {
+ /**
+ * Returns a global variable from PHP file by executing the file.
+ * @param string $_filename Path to the file.
+ * @param string $_variable Name of the variable.
+ * @return mixed The variable contents or null.
+ */
+ public static function loadVariableFromPHPFile( $_filename, $_variable ) {
+ if ( !file_exists( $_filename ) ) {
+ return null;
+ } else {
+ require $_filename;
+
+ return $$_variable ?? null;
+ }
+ }
+}