Preferences: Fix error messages and convenience configuration

refs #4648
This commit is contained in:
Marius Hein 2013-08-29 13:34:36 +02:00 committed by Johannes Meyer
parent 772d27bb89
commit 7be7335bdd
4 changed files with 20 additions and 6 deletions

View File

View File

@ -1 +0,0 @@
# Keep this directory

View File

@ -249,6 +249,15 @@ class Web extends ApplicationBootstrap
$preferences->attach($sessionStore); $preferences->attach($sessionStore);
if ($this->getConfig()->preferences !== null) { if ($this->getConfig()->preferences !== null) {
if (!$this->getConfig()->preferences->type) {
Logger::info(
'Preferences provider configuration error. No type was omitted. For convenience we enable '
. 'file based ini provider for you.'
);
$this->getConfig()->preferences->type = 'ini';
}
$path = Config::resolvePath($this->getConfig()->preferences->configPath); $path = Config::resolvePath($this->getConfig()->preferences->configPath);
if (is_dir($path) === false) { if (is_dir($path) === false) {
Logger::error( Logger::error(

View File

@ -28,11 +28,12 @@
namespace Icinga\User\Preferences; namespace Icinga\User\Preferences;
use Icinga\User;
use Icinga\Exception\ProgrammingError;
use \Icinga\Application\DbAdapterFactory;
use \Zend_Config; use \Zend_Config;
use \Zend_Db; use \Zend_Db;
use \Icinga\User;
use \Icinga\Exception\ProgrammingError;
use \Icinga\Application\DbAdapterFactory;
use Icinga\Application\Logger;
/** /**
* Create preference stores from zend config * Create preference stores from zend config
@ -66,7 +67,10 @@ final class StoreFactory
$store = new $class(); $store = new $class();
if (!$store instanceof FlushObserverInterface) { if (!$store instanceof FlushObserverInterface) {
throw new ProgrammingError('Not instance of FlushObserverInterface: '. $class); throw new ProgrammingError(
'Preferences StoreFactory could not create provider (class ' . $class . '). '
. 'Class is not instance of FlushObserverInterface.'
);
} }
$items = $config->toArray(); $items = $config->toArray();
@ -88,6 +92,8 @@ final class StoreFactory
return $store; return $store;
} }
throw new ProgrammingError('Could not instantiate class: '. $class); throw new ProgrammingError(
'Preferences StoreFactory could not create provider (class ' . $class . '). Class not found.'
);
} }
} }