30 lines
781 B
PHP
30 lines
781 B
PHP
<?php
|
|
|
|
class Configuration {
|
|
|
|
private static $parameters;
|
|
|
|
public static function get($nom, $default = null) {
|
|
if (isset(self::getParameters()[$nom])) {
|
|
$value = self::getParameters()[$nom];
|
|
}
|
|
else {
|
|
$value = $default;
|
|
}
|
|
return $value;
|
|
}
|
|
|
|
private static function getParameters() {
|
|
if (self::$parameters == null) {
|
|
$pathFile = $GLOBALS['app_path']."Config/config.ini";
|
|
|
|
if (!file_exists($pathFile)) {
|
|
throw new Exception("Aucun fichier de configuration trouvé");
|
|
}
|
|
else {
|
|
self::$parameters = parse_ini_file($pathFile);
|
|
}
|
|
}
|
|
return self::$parameters;
|
|
}
|
|
} |