Use "ini" as preferences store in case preferences are not configured

refs #8234
This commit is contained in:
Johannes Meyer 2015-01-23 16:07:38 +01:00
parent 359336243c
commit d452f3218d
3 changed files with 2 additions and 12 deletions

View File

@ -7,7 +7,6 @@ use Icinga\Web\Url;
use Icinga\Web\Widget\Tab; use Icinga\Web\Widget\Tab;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Forms\PreferenceForm; use Icinga\Forms\PreferenceForm;
use Icinga\Exception\ConfigurationError;
use Icinga\User\Preferences\PreferencesStore; use Icinga\User\Preferences\PreferencesStore;
/** /**
@ -40,9 +39,6 @@ class PreferenceController extends BasePreferenceController
public function indexAction() public function indexAction()
{ {
$storeConfig = Config::app()->getSection('preferences'); $storeConfig = Config::app()->getSection('preferences');
if ($storeConfig->isEmpty()) {
throw new ConfigurationError(t('You need to configure how to store preferences first.'));
}
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$form = new PreferenceForm(); $form = new PreferenceForm();

View File

@ -63,7 +63,7 @@ class Manager
); );
$config = new Config(); $config = new Config();
} }
if ($config->hasSection('preferences')) { if ($config->get('preferences', 'store', 'ini') !== 'none') {
$preferencesConfig = $config->getSection('preferences'); $preferencesConfig = $config->getSection('preferences');
try { try {
$preferencesStore = PreferencesStore::create( $preferencesStore = PreferencesStore::create(

View File

@ -117,13 +117,7 @@ abstract class PreferencesStore
*/ */
public static function create(ConfigObject $config, User $user) public static function create(ConfigObject $config, User $user)
{ {
if (($type = $config->store) === null) { $type = ucfirst(strtolower($config->get('store', 'ini')));
throw new ConfigurationError(
'Preferences configuration is missing the store directive'
);
}
$type = ucfirst(strtolower($type));
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store'; $storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
if (!class_exists($storeClass)) { if (!class_exists($storeClass)) {
throw new ConfigurationError( throw new ConfigurationError(