mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Application/Bootstrap: Throw Exception if timezone isn't valid
refs #4440
This commit is contained in:
parent
55f93389ba
commit
9170523afa
@ -28,12 +28,13 @@
|
|||||||
|
|
||||||
namespace Icinga\Application;
|
namespace Icinga\Application;
|
||||||
|
|
||||||
|
use \DateTimeZone;
|
||||||
|
use \Exception;
|
||||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||||
use Icinga\Application\Platform;
|
use Icinga\Application\Platform;
|
||||||
use Icinga\Exception\ProgrammingError;
|
|
||||||
use \Icinga\Application\Config;
|
use \Icinga\Application\Config;
|
||||||
use Zend_Loader_Autoloader;
|
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
use Zend_Loader_Autoloader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class bootstraps a thin Icinga application layer
|
* This class bootstraps a thin Icinga application layer
|
||||||
@ -264,7 +265,6 @@ abstract class ApplicationBootstrap
|
|||||||
*/
|
*/
|
||||||
public function setupAutoloader()
|
public function setupAutoloader()
|
||||||
{
|
{
|
||||||
require $this->libDir. '/Icinga/Exception/ProgrammingError.php';
|
|
||||||
require $this->libDir. '/Icinga/Application/Loader.php';
|
require $this->libDir. '/Icinga/Application/Loader.php';
|
||||||
|
|
||||||
$this->loader = new Loader();
|
$this->loader = new Loader();
|
||||||
@ -340,16 +340,20 @@ abstract class ApplicationBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup default timezone
|
* Setup timezone
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
|
* @throws \Icinga\Exception\ConfigurationError if the timezone in config.ini isn't valid
|
||||||
*/
|
*/
|
||||||
protected function setupTimezone()
|
protected function setupTimezone()
|
||||||
{
|
{
|
||||||
date_default_timezone_set(
|
$tz = $this->config->global->get('timezone', 'UTC');
|
||||||
$this->config->global->get('timezone', 'UTC')
|
try {
|
||||||
);
|
new DateTimeZone($tz);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new ConfigurationError(t('Invalid timezone') . ' "' . $tz . '"');
|
||||||
|
}
|
||||||
|
date_default_timezone_set($tz);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user