From 24879db1f73c85b121702ba8c6ea36bae285c7c3 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 12 Dec 2016 17:41:03 +0100 Subject: Add default value for list_mode --- src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php | 3 +++ src/Wallabag/CoreBundle/DependencyInjection/Configuration.php | 6 ++++++ .../CoreBundle/DependencyInjection/WallabagCoreExtension.php | 2 ++ src/Wallabag/UserBundle/EventListener/CreateConfigListener.php | 8 +++++++- src/Wallabag/UserBundle/Resources/config/services.yml | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php index 45358022..3d4d5def 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php @@ -22,6 +22,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $adminConfig->setLanguage('en'); $adminConfig->setPocketConsumerKey('xxxxx'); $adminConfig->setActionMarkAsRead(0); + $adminConfig->setListMode(0); $manager->persist($adminConfig); @@ -34,6 +35,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $bobConfig->setLanguage('fr'); $bobConfig->setPocketConsumerKey(null); $bobConfig->setActionMarkAsRead(1); + $bobConfig->setListMode(1); $manager->persist($bobConfig); @@ -46,6 +48,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $emptyConfig->setLanguage('en'); $emptyConfig->setPocketConsumerKey(null); $emptyConfig->setActionMarkAsRead(0); + $emptyConfig->setListMode(0); $manager->persist($emptyConfig); diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 3a3da024..006a18c3 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -41,6 +41,12 @@ class Configuration implements ConfigurationInterface ->end() ->scalarNode('fetching_error_message') ->end() + ->scalarNode('action_mark_as_read') + ->defaultValue(1) + ->end() + ->scalarNode('list_mode') + ->defaultValue(1) + ->end() ->end() ; diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index b4992d54..aa9ee339 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -23,6 +23,8 @@ class WallabagCoreExtension extends Extension $container->setParameter('wallabag_core.version', $config['version']); $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); $container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']); + $container->setParameter('wallabag_core.action_mark_as_read', $config['action_mark_as_read']); + $container->setParameter('wallabag_core.list_mode', $config['list_mode']); $container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); diff --git a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php index 8e2f04e9..0bdd1cae 100644 --- a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php +++ b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php @@ -21,8 +21,10 @@ class CreateConfigListener implements EventSubscriberInterface private $rssLimit; private $language; private $readingSpeed; + private $actionMarkAsRead; + private $listMode; - public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed) + public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode) { $this->em = $em; $this->theme = $theme; @@ -30,6 +32,8 @@ class CreateConfigListener implements EventSubscriberInterface $this->rssLimit = $rssLimit; $this->language = $language; $this->readingSpeed = $readingSpeed; + $this->actionMarkAsRead = $actionMarkAsRead; + $this->listMode = $listMode; } public static function getSubscribedEvents() @@ -51,6 +55,8 @@ class CreateConfigListener implements EventSubscriberInterface $config->setRssLimit($this->rssLimit); $config->setLanguage($this->language); $config->setReadingSpeed($this->readingSpeed); + $config->setActionMarkAsRead($this->actionMarkAsRead); + $config->setListMode($this->listMode); $this->em->persist($config); $this->em->flush(); diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index 164a25ec..72f6f12c 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -31,5 +31,7 @@ services: - "%wallabag_core.rss_limit%" - "%wallabag_core.language%" - "%wallabag_core.reading_speed%" + - "%wallabag_core.action_mark_as_read%" + - "%wallabag_core.list_mode%" tags: - { name: kernel.event_subscriber } -- cgit v1.2.3