mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +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;
|
||||
|
||||
use \DateTimeZone;
|
||||
use \Exception;
|
||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use \Icinga\Application\Config;
|
||||
use Zend_Loader_Autoloader;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Zend_Loader_Autoloader;
|
||||
|
||||
/**
|
||||
* This class bootstraps a thin Icinga application layer
|
||||
@ -264,7 +265,6 @@ abstract class ApplicationBootstrap
|
||||
*/
|
||||
public function setupAutoloader()
|
||||
{
|
||||
require $this->libDir. '/Icinga/Exception/ProgrammingError.php';
|
||||
require $this->libDir. '/Icinga/Application/Loader.php';
|
||||
|
||||
$this->loader = new Loader();
|
||||
@ -340,16 +340,20 @@ abstract class ApplicationBootstrap
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup default timezone
|
||||
* Setup timezone
|
||||
*
|
||||
* @return self
|
||||
* @throws \Icinga\Exception\ConfigurationError if the timezone in config.ini isn't valid
|
||||
*/
|
||||
protected function setupTimezone()
|
||||
{
|
||||
date_default_timezone_set(
|
||||
$this->config->global->get('timezone', 'UTC')
|
||||
);
|
||||
|
||||
$tz = $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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user