Commit initial
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user