summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/utils/ResourceLoader.php
blob: 1a8e5c29427aa65a8b2404d1174912ff926ccef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
		}
	}
}