]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add default value for list_mode 2697/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 12 Dec 2016 16:41:03 +0000 (17:41 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 12 Dec 2016 16:41:03 +0000 (17:41 +0100)
app/DoctrineMigrations/Version20161128084725.php
app/config/config.yml
src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php
src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
src/Wallabag/UserBundle/EventListener/CreateConfigListener.php
src/Wallabag/UserBundle/Resources/config/services.yml
tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php

index 242d59006c3ffe876924a5f97939e0c7b35021ee..ea370076c85fca183a5485dda9d017afa5a0c592 100644 (file)
@@ -35,7 +35,7 @@ class Version20161128084725 extends AbstractMigration implements ContainerAwareI
         $configTable = $schema->getTable($this->getTable('config'));
         $this->skipIf($configTable->hasColumn('list_mode'), 'It seems that you already played this migration.');
 
-        $configTable->addColumn('list_mode', 'integer');
+        $configTable->addColumn('list_mode', 'integer', ['notnull' => false]);
     }
 
     /**
index 6b1ed05669ef861e532207a75f7dea1915e35d47..d52f37c818f190aede838c00ce0dad98ffad07d4 100644 (file)
@@ -51,6 +51,8 @@ wallabag_core:
     rss_limit: 50
     reading_speed: 1
     cache_lifetime: 10
+    action_mark_as_read: 1
+    list_mode: 1
     fetching_error_message: |
         wallabag can't retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.
 
index 4535802279019a95d57982c4afde5133b01f5a9d..3d4d5def9aa2c6c02d97652bc62b8f764046159f 100644 (file)
@@ -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);
 
index 3a3da0246f2d5869537a4b620fcb80782bcee99d..006a18c397a6ceea925ef29dcd5ea254c528eb52 100644 (file)
@@ -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()
         ;
 
index b4992d545066506cf4824d0357977f6dfc08ac2b..aa9ee339adebd24a1e7d9282eb6b70714396e740 100644 (file)
@@ -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'));
index 8e2f04e9beca05428dc5c0c4d698e0ddb85252c2..0bdd1cae061d365a751911de1fc73f5f34c34e00 100644 (file)
@@ -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();
index 164a25ec1e77060ec32d9cadcaa61ee1c89fc49b..72f6f12c1bb5f47c4191977ae41bb77af17c8f73 100644 (file)
@@ -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 }
index a78b77bc37c332c628e7b405732a3339413899db..01796dedd4b7d95ce682b6616c3f336ec69b94e7 100644 (file)
@@ -31,6 +31,8 @@ class CreateConfigListenerTest extends \PHPUnit_Framework_TestCase
             20,
             50,
             'fr',
+            1,
+            1,
             1
         );