From bc78968764c741019a6b866ad434678cdbecbba4 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 20 Jan 2016 19:54:57 +0100 Subject: Move default configuration out of parameters These default configuration value shouldn't be in parameters.yml. --- app/config/config.yml | 4 ++++ app/config/parameters.yml.dist | 7 ------- app/config/tests/parameters.yml.dist.mysql | 7 ------- app/config/tests/parameters.yml.dist.pgsql | 7 ------- app/config/tests/parameters.yml.dist.sqlite | 7 ------- src/Wallabag/CoreBundle/Command/InstallCommand.php | 8 ++++---- src/Wallabag/CoreBundle/Controller/ConfigController.php | 8 ++++---- .../CoreBundle/DependencyInjection/Configuration.php | 12 ++++++++++++ .../CoreBundle/DependencyInjection/WallabagCoreExtension.php | 5 +++++ src/Wallabag/CoreBundle/Resources/config/services.yml | 8 ++++---- 10 files changed, 33 insertions(+), 40 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index a6cfc67d..943365e8 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -33,6 +33,10 @@ wallabag_core: fr: 'Français' de: 'Deutsch' tr: 'Türkçe' + items_on_page: 12 + theme: material + language: en + rss_limit: 50 wallabag_import: allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index e4fcbd74..f9555676 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -68,12 +68,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index f902f239..e0e92760 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -58,12 +58,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en_US - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.pgsql b/app/config/tests/parameters.yml.dist.pgsql index 76685b14..e6e7636c 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -58,12 +58,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en_US - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.sqlite b/app/config/tests/parameters.yml.dist.sqlite index cdafb1b1..c47392a3 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -58,12 +58,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en_US - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index da099a19..7a7e3a64 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -205,10 +205,10 @@ class InstallCommand extends ContainerAwareCommand $em->persist($user); $config = new Config($user); - $config->setTheme($this->getContainer()->getParameter('theme')); - $config->setItemsPerPage($this->getContainer()->getParameter('items_on_page')); - $config->setRssLimit($this->getContainer()->getParameter('rss_limit')); - $config->setLanguage($this->getContainer()->getParameter('language')); + $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); + $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); + $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); + $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); $em->persist($config); diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 6c375909..4ece6431 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -133,10 +133,10 @@ class ConfigController extends Controller $userManager->updateUser($newUser, true); $config = new Config($newUser); - $config->setTheme($this->container->getParameter('theme')); - $config->setItemsPerPage($this->container->getParameter('items_on_page')); - $config->setRssLimit($this->container->getParameter('rss_limit')); - $config->setLanguage($this->container->getParameter('language')); + $config->setTheme($this->container->getParameter('wallabag_core.theme')); + $config->setItemsPerPage($this->container->getParameter('wallabag_core.items_on_page')); + $config->setRssLimit($this->container->getParameter('wallabag_core.rss_limit')); + $config->setLanguage($this->container->getParameter('wallabag_core.language')); $em->persist($config); diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 32acd1f1..4d5a63f8 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -17,6 +17,18 @@ class Configuration implements ConfigurationInterface ->arrayNode('languages') ->prototype('scalar')->end() ->end() + ->integerNode('items_on_page') + ->defaultValue(12) + ->end() + ->scalarNode('theme') + ->defaultValue('material') + ->end() + ->scalarNode('language') + ->defaultValue('en') + ->end() + ->integerNode('rss_limit') + ->defaultValue(50) + ->end() ->end() ; diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 9ff9b732..73bbffe1 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -13,7 +13,12 @@ class WallabagCoreExtension extends Extension { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); + $container->setParameter('wallabag_core.languages', $config['languages']); + $container->setParameter('wallabag_core.items_on_page', $config['items_on_page']); + $container->setParameter('wallabag_core.theme', $config['theme']); + $container->setParameter('wallabag_core.language', $config['language']); + $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 25d71cba..6a1afcc0 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -76,10 +76,10 @@ services: class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener arguments: - "@doctrine.orm.entity_manager" - - %theme% - - %items_on_page% - - %rss_limit% - - %language% + - %wallabag_core.theme% + - %wallabag_core.items_on_page% + - %wallabag_core.rss_limit% + - %wallabag_core.language% tags: - { name: kernel.event_subscriber } -- cgit v1.2.3