]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #1510 from wallabag/v2-sf3
authorNicolas Lœuillet <nicolas@loeuillet.org>
Sat, 7 Nov 2015 12:39:30 +0000 (13:39 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Sat, 7 Nov 2015 12:39:30 +0000 (13:39 +0100)
v2 – Fix some deprecated for Symfony3

14 files changed:
.travis.yml
app/config/routing.yml
composer.json
composer.lock
phpunit.xml.dist
src/Wallabag/ApiBundle/Controller/WallabagRestController.php
src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php
src/Wallabag/CoreBundle/Command/InstallCommand.php
src/Wallabag/CoreBundle/Controller/ConfigController.php
src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
src/Wallabag/CoreBundle/Resources/config/services.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php

index d535582081fbae7f341cb35d33c9882bd70e6af2..df3a5c7255654f69eba1a1ead9d669fee3c5c575 100644 (file)
@@ -51,7 +51,7 @@ before_script:
 
 script:
     - ant prepare-$DB
-    - bin/phpunit --exclude-group command-doctrine -v
+    - SYMFONY_DEPRECATIONS_HELPER=weak bin/phpunit --exclude-group command-doctrine -v
 
 # after_script:
     # - |
index af3e32b180178821a0451182690c5f735af3d717..0f7b61fb3427991b7fad329357ae82688a57dc3f 100644 (file)
@@ -1,10 +1,10 @@
 wallabag_api:
     resource: "@WallabagApiBundle/Resources/config/routing.yml"
-    prefix:   /
+    prefix: /
 
 app:
     resource: @WallabagCoreBundle/Controller/
-    type:     annotation
+    type: annotation
 
 doc-api:
     resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
@@ -16,10 +16,10 @@ rest :
     prefix : /api
 
 homepage:
-    pattern:   "/{page}"
-    defaults:  { _controller: WallabagCoreBundle:Entry:showUnread, page : 1 }
+    path: "/{page}"
+    defaults: { _controller: WallabagCoreBundle:Entry:showUnread, page : 1 }
     requirements:
-        page:  \d+
+        page: \d+
 
 fos_user:
     resource: "@FOSUserBundle/Resources/config/routing/all.xml"
index e16de833e797e50cc34f32fb11408422f3b39eb4..b8c936f0d0cc78285f1b7a62cbf63ea0dae29a86 100644 (file)
@@ -60,7 +60,8 @@
     "require-dev": {
         "doctrine/doctrine-fixtures-bundle": "~2.2.0",
         "sensio/generator-bundle": "~2.5",
-        "phpunit/phpunit": "~4.4"
+        "phpunit/phpunit": "~4.4",
+        "symfony/phpunit-bridge": "~2.7.0"
     },
     "scripts": {
         "post-install-cmd": [
index 368f9f95a164723be98b8fb561160d56e23b5b22..ee6e483a0fd2cd3c681f396485679e4c2d18042c 100644 (file)
@@ -4,8 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "7fb67fafde0e24c1802714a2a47da5e1",
-    "content-hash": "372936ba75537d8422a8e63bd419c213",
+    "hash": "01e7829e7ff2b39b288871661bb05e9a",
+    "content-hash": "76830bc9c2cd6f600613c9eea7c0f1b1",
     "packages": [
         {
             "name": "doctrine/annotations",
         },
         {
             "name": "doctrine/cache",
-            "version": "v1.5.0",
+            "version": "v1.5.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/cache.git",
-                "reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f"
+                "reference": "2b9cec5a5e722010cbebc91713d4c11eaa064d5e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/cache/zipball/eb8a73619af4f1c8711e2ce482f5de3643258a1f",
-                "reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f",
+                "url": "https://api.github.com/repos/doctrine/cache/zipball/2b9cec5a5e722010cbebc91713d4c11eaa064d5e",
+                "reference": "2b9cec5a5e722010cbebc91713d4c11eaa064d5e",
                 "shasum": ""
             },
             "require": {
                 "cache",
                 "caching"
             ],
-            "time": "2015-10-28 11:27:45"
+            "time": "2015-11-02 18:35:48"
         },
         {
             "name": "doctrine/collections",
         },
         {
             "name": "doctrine/doctrine-bundle",
-            "version": "v1.5.2",
+            "version": "1.6.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/DoctrineBundle.git",
-                "reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3"
+                "reference": "a5b3ba908ba68f3e14e42762a7b940fde65ed7da"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3",
-                "reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3",
+                "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/a5b3ba908ba68f3e14e42762a7b940fde65ed7da",
+                "reference": "a5b3ba908ba68f3e14e42762a7b940fde65ed7da",
                 "shasum": ""
             },
             "require": {
                 "orm",
                 "persistence"
             ],
-            "time": "2015-08-31 14:47:06"
+            "time": "2015-11-04 21:33:02"
         },
         {
             "name": "doctrine/doctrine-cache-bundle",
-            "version": "v1.0.1",
-            "target-dir": "Doctrine/Bundle/DoctrineCacheBundle",
+            "version": "1.2.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/DoctrineCacheBundle.git",
-                "reference": "e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d"
+                "reference": "3233bc78e222d528ca89a6a47d48d6f37888e95e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/DoctrineCacheBundle/zipball/e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d",
-                "reference": "e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d",
+                "url": "https://api.github.com/repos/doctrine/DoctrineCacheBundle/zipball/3233bc78e222d528ca89a6a47d48d6f37888e95e",
+                "reference": "3233bc78e222d528ca89a6a47d48d6f37888e95e",
                 "shasum": ""
             },
             "require": {
-                "doctrine/cache": "~1.3",
+                "doctrine/cache": "^1.4.2",
                 "doctrine/inflector": "~1.0",
                 "php": ">=5.3.2",
-                "symfony/doctrine-bridge": "~2.2",
-                "symfony/framework-bundle": "~2.2",
-                "symfony/security": "~2.2"
+                "symfony/doctrine-bridge": "~2.2|~3.0",
+                "symfony/security-acl": "~2.3|~3.0"
             },
             "require-dev": {
                 "instaclick/coding-standard": "~1.1",
                 "instaclick/object-calisthenics-sniffs": "dev-master",
                 "instaclick/symfony2-coding-standard": "dev-remaster",
-                "phpunit/phpunit": "~3.7",
+                "phpunit/phpunit": "~4",
                 "satooshi/php-coveralls": "~0.6.1",
-                "squizlabs/php_codesniffer": "dev-master",
-                "symfony/console": "~2.2",
-                "symfony/finder": "~2.2",
-                "symfony/validator": "~2.2",
-                "symfony/yaml": "~2.2"
+                "squizlabs/php_codesniffer": "~1.5",
+                "symfony/console": "~2.2|~3.0",
+                "symfony/finder": "~2.2|~3.0",
+                "symfony/framework-bundle": "~2.2|~3.0",
+                "symfony/phpunit-bridge": "~2.7|~3.0",
+                "symfony/validator": "~2.2|~3.0",
+                "symfony/yaml": "~2.2|~3.0"
             },
             "type": "symfony-bundle",
             "extra": {
                 }
             },
             "autoload": {
-                "psr-0": {
-                    "Doctrine\\Bundle\\DoctrineCacheBundle": ""
+                "psr-4": {
+                    "Doctrine\\Bundle\\DoctrineCacheBundle\\": ""
                 }
             },
             "notification-url": "https://packagist.org/downloads/",
                     "email": "fabien@symfony.com"
                 }
             ],
-            "description": "Symfony2 Bundle for Doctrine Cache",
+            "description": "Symfony Bundle for Doctrine Cache",
             "homepage": "http://www.doctrine-project.org",
             "keywords": [
                 "cache",
                 "caching"
             ],
-            "time": "2014-11-28 09:43:36"
+            "time": "2015-11-05 13:48:27"
         },
         {
             "name": "doctrine/inflector",
-            "version": "v1.0.1",
+            "version": "v1.1.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/inflector.git",
-                "reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604"
+                "reference": "90b2128806bfde671b6952ab8bea493942c1fdae"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604",
-                "reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604",
+                "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae",
+                "reference": "90b2128806bfde671b6952ab8bea493942c1fdae",
                 "shasum": ""
             },
             "require": {
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.0.x-dev"
+                    "dev-master": "1.1.x-dev"
                 }
             },
             "autoload": {
                 "singularize",
                 "string"
             ],
-            "time": "2014-12-20 21:24:13"
+            "time": "2015-11-06 14:35:42"
         },
         {
             "name": "doctrine/instantiator",
             "source": {
                 "type": "git",
                 "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
-                "reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83"
+                "reference": "45d6f40178216a840885b4ca6d7de9e67068568a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/d5b28c367d393f9d9fbc48c4138b2a74d51c0c83",
-                "reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83",
+                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/45d6f40178216a840885b4ca6d7de9e67068568a",
+                "reference": "45d6f40178216a840885b4ca6d7de9e67068568a",
                 "shasum": ""
             },
             "require": {
             "keywords": [
                 "User management"
             ],
-            "time": "2015-09-15 13:15:07"
+            "time": "2015-11-03 10:24:23"
         },
         {
             "name": "guzzlehttp/guzzle",
         },
         {
             "name": "twig/twig",
-            "version": "v1.23.0",
+            "version": "v1.23.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/twigphp/Twig.git",
-                "reference": "5868cd822fd6cf626d5f805439575f9c323cee2a"
+                "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/twigphp/Twig/zipball/5868cd822fd6cf626d5f805439575f9c323cee2a",
-                "reference": "5868cd822fd6cf626d5f805439575f9c323cee2a",
+                "url": "https://api.github.com/repos/twigphp/Twig/zipball/d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
+                "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
                 "shasum": ""
             },
             "require": {
             "keywords": [
                 "templating"
             ],
-            "time": "2015-10-29 23:29:01"
+            "time": "2015-11-05 12:49:06"
         },
         {
             "name": "willdurand/hateoas",
             ],
             "description": "This bundle generates code for you",
             "time": "2015-03-17 06:36:52"
+        },
+        {
+            "name": "symfony/phpunit-bridge",
+            "version": "v2.7.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/phpunit-bridge.git",
+                "reference": "896bbd1742a6ecd2f7904167bdb6bf88eb6cfbe4"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/896bbd1742a6ecd2f7904167bdb6bf88eb6cfbe4",
+                "reference": "896bbd1742a6ecd2f7904167bdb6bf88eb6cfbe4",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "suggest": {
+                "symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
+            },
+            "type": "symfony-bridge",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.7-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "bootstrap.php"
+                ],
+                "psr-4": {
+                    "Symfony\\Bridge\\PhpUnit\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony PHPUnit Bridge",
+            "homepage": "https://symfony.com",
+            "time": "2015-09-27 10:08:51"
         }
     ],
     "aliases": [],
index 6f6269a4cfe3659a17f42245c4a2b6e03506de8e..7bec5b5e903648a70a0b988120c6e8502154ab47 100644 (file)
 
     <php>
         <server name="KERNEL_DIR" value="./app/" />
+        <!--
+          Avoid tests to fail because of deprecated stuff
+          see: http://symfony.com/doc/current/cookbook/upgrade/major_version.html#deprecations-in-phpunit
+        -->
+        <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
     </php>
 
     <filter>
index 1fee56ad14693c812e8b0896a0693faf8dd41d14..74bfe4dcdb286a3337e00d889a80ffb3d1918b05 100644 (file)
@@ -40,7 +40,7 @@ class WallabagRestController extends FOSRestController
 
     private function validateAuthentication()
     {
-        if (false === $this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
+        if (false === $this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
             throw new AccessDeniedException();
         }
     }
@@ -347,7 +347,7 @@ class WallabagRestController extends FOSRestController
      */
     private function validateUserAccess($requestUserId)
     {
-        $user = $this->get('security.context')->getToken()->getUser();
+        $user = $this->get('security.token_storage')->getToken()->getUser();
         if ($requestUserId != $user->getId()) {
             throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId());
         }
index 119889b3869b468a6ff8bc0f95521ee195845f2f..09cde0f602766995b7c48b02a0e85c121390fa40 100644 (file)
@@ -25,7 +25,6 @@ abstract class AbstractControllerTest extends WebTestCase
         $client = static::createClient();
         $container = $client->getContainer();
 
-        $session = $container->get('session');
         /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
         $userManager = $container->get('fos_user.user_manager');
         /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
@@ -36,9 +35,10 @@ abstract class AbstractControllerTest extends WebTestCase
         $loginManager->loginUser($firewallName, $user);
 
         // save the login token into the session and put it in a cookie
-        $container->get('session')->set('_security_'.$firewallName,
-            serialize($container->get('security.context')->getToken()));
+        $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
         $container->get('session')->save();
+
+        $session = $container->get('session');
         $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
 
         return $client;
index 6ebbd93c0e2d9cd04787b1ee9f62c9d808cd3749..808baaf68ec7257270d620d1028cfa763ce59377 100644 (file)
@@ -8,6 +8,9 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\ArrayInput;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Output\NullOutput;
+use Symfony\Component\Console\Question\Question;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
+use Symfony\Component\Console\Helper\Table;
 use Wallabag\UserBundle\Entity\User;
 use Wallabag\CoreBundle\Entity\Config;
 
@@ -85,10 +88,11 @@ class InstallCommand extends ContainerAwareCommand
         }
         $rows[] = array($label, $status, $help);
 
-        $this->getHelper('table')
+        $table = new Table($this->defaultOutput);
+        $table
             ->setHeaders(array('Checked', 'Status', 'Recommendation'))
             ->setRows($rows)
-            ->render($this->defaultOutput);
+            ->render();
 
         if (!$fulfilled) {
             throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.');
@@ -130,9 +134,10 @@ class InstallCommand extends ContainerAwareCommand
             return $this;
         }
 
-        $dialog = $this->getHelper('dialog');
+        $questionHelper = $this->getHelper('question');
+        $question = new ConfirmationQuestion('It appears that your database already exists. Would you like to reset it? (y/N)', false);
 
-        if ($dialog->askConfirmation($this->defaultOutput, '<question>It appears that your database already exists. Would you like to reset it? (y/N)</question> ', false)) {
+        if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
             $this->defaultOutput->writeln('Droping database, creating database and schema');
 
             $this
@@ -141,7 +146,8 @@ class InstallCommand extends ContainerAwareCommand
                 ->runCommand('doctrine:schema:create')
             ;
         } elseif ($this->isSchemaPresent()) {
-            if ($dialog->askConfirmation($this->defaultOutput, '<question>Seems like your database contains schema. Do you want to reset it? (y/N)</question> ', false)) {
+            $question = new ConfirmationQuestion('Seems like your database contains schema. Do you want to reset it? (y/N)', false);
+            if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
                 $this->defaultOutput->writeln('Droping schema and creating schema');
 
                 $this
@@ -160,17 +166,6 @@ class InstallCommand extends ContainerAwareCommand
         $this->defaultOutput->writeln('Clearing the cache');
         $this->runCommand('cache:clear');
 
-        /*
-        if ($this->getHelperSet()->get('dialog')->askConfirmation($this->defaultOutput, '<question>Load fixtures (Y/N)?</question>', false)) {
-            $doctrineConfig = $this->getContainer()->get('doctrine.orm.entity_manager')->getConnection()->getConfiguration();
-            $logger = $doctrineConfig->getSQLLogger();
-            // speed up fixture load
-            $doctrineConfig->setSQLLogger(null);
-            $this->runCommand('doctrine:fixtures:load');
-            $doctrineConfig->setSQLLogger($logger);
-        }
-        */
-
         $this->defaultOutput->writeln('');
 
         return $this;
@@ -180,9 +175,10 @@ class InstallCommand extends ContainerAwareCommand
     {
         $this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>');
 
-        $dialog = $this->getHelperSet()->get('dialog');
+        $questionHelper = $this->getHelperSet()->get('question');
+        $question = new ConfirmationQuestion('Would you like to create a new user ? (y/N)', false);
 
-        if (false === $dialog->askConfirmation($this->defaultOutput, '<question>Would you like to create a new user ? (y/N)</question>', true)) {
+        if (!$questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
             return $this;
         }
 
@@ -190,9 +186,16 @@ class InstallCommand extends ContainerAwareCommand
 
         $userManager = $this->getContainer()->get('fos_user.user_manager');
         $user = $userManager->createUser();
-        $user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
-        $user->setPlainPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
-        $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', ''));
+
+        $question = new Question('Username (default: wallabag) :', 'wallabag');
+        $user->setUsername($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question));
+
+        $question = new Question('Password (default: wallabag) :', 'wallabag');
+        $user->setPlainPassword($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question));
+
+        $question = new Question('Email:', '');
+        $user->setEmail($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question));
+
         $user->setEnabled(true);
 
         $em->persist($user);
index ca4acc6ae450a3acd00af827ef3090581eb543d5..8bbe4ca06e5fac841566fc3676335d45f419457c 100644 (file)
@@ -29,7 +29,7 @@ class ConfigController extends Controller
         $user = $this->getUser();
 
         // handle basic config detail (this form is defined as a service)
-        $configForm = $this->createForm('config', $config);
+        $configForm = $this->createForm('config', $config, array('action' => $this->generateUrl('config')));
         $configForm->handleRequest($request);
 
         if ($configForm->isValid()) {
@@ -49,7 +49,7 @@ class ConfigController extends Controller
         }
 
         // handle changing password
-        $pwdForm = $this->createForm(new ChangePasswordType());
+        $pwdForm = $this->createForm(new ChangePasswordType(), null, array('action' => $this->generateUrl('config').'#set4'));
         $pwdForm->handleRequest($request);
 
         if ($pwdForm->isValid()) {
@@ -65,7 +65,10 @@ class ConfigController extends Controller
         }
 
         // handle changing user information
-        $userForm = $this->createForm(new UserInformationType(), $user, array('validation_groups' => array('Profile')));
+        $userForm = $this->createForm(new UserInformationType(), $user, array(
+            'validation_groups' => array('Profile'),
+            'action' => $this->generateUrl('config').'#set3',
+        ));
         $userForm->handleRequest($request);
 
         if ($userForm->isValid()) {
@@ -80,7 +83,7 @@ class ConfigController extends Controller
         }
 
         // handle rss information
-        $rssForm = $this->createForm(new RssType(), $config);
+        $rssForm = $this->createForm(new RssType(), $config, array('action' => $this->generateUrl('config').'#set2'));
         $rssForm->handleRequest($request);
 
         if ($rssForm->isValid()) {
@@ -99,7 +102,10 @@ class ConfigController extends Controller
         $newUser = $userManager->createUser();
         // enable created user by default
         $newUser->setEnabled(true);
-        $newUserForm = $this->createForm(new NewUserType(), $newUser, array('validation_groups' => array('Profile')));
+        $newUserForm = $this->createForm(new NewUserType(), $newUser, array(
+            'validation_groups' => array('Profile'),
+            'action' => $this->generateUrl('config').'#set5',
+        ));
         $newUserForm->handleRequest($request);
 
         if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
index 054a375227c0345c7712c660c2682e81161d050a..23e98042c60563b985584eefa2d26ac1d00323bb 100644 (file)
@@ -3,7 +3,7 @@
 namespace Wallabag\CoreBundle\Helper;
 
 use Liip\ThemeBundle\Helper\DeviceDetectionInterface;
-use Symfony\Component\Security\Core\SecurityContextInterface;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
 use Wallabag\UserBundle\Entity\User;
 
 /**
@@ -14,16 +14,16 @@ use Wallabag\UserBundle\Entity\User;
  */
 class DetectActiveTheme implements DeviceDetectionInterface
 {
-    protected $securityContext;
+    protected $tokenStorage;
     protected $defaultTheme;
 
     /**
-     * @param SecurityContextInterface $securityContext Needed to retrieve the current user
-     * @param string                   $defaultTheme    Default theme when user isn't logged in
+     * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user
+     * @param string                $defaultTheme Default theme when user isn't logged in
      */
-    public function __construct(SecurityContextInterface $securityContext, $defaultTheme)
+    public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme)
     {
-        $this->securityContext = $securityContext;
+        $this->tokenStorage = $tokenStorage;
         $this->defaultTheme = $defaultTheme;
     }
 
@@ -42,7 +42,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
      */
     public function getType()
     {
-        $token = $this->securityContext->getToken();
+        $token = $this->tokenStorage->getToken();
 
         if (is_null($token)) {
             return $this->defaultTheme;
index 3c479ff666607b0cce074c14c9c44f81c0b4e16a..debbf39e0eb4ab9672e5ccad38567afd18062018 100644 (file)
@@ -2,7 +2,7 @@ services:
     wallabag_core.helper.detect_active_theme:
         class: Wallabag\CoreBundle\Helper\DetectActiveTheme
         arguments:
-            - @security.context
+            - @security.token_storage
             - %theme% # default theme from parameters.yml
 
     # custom form type
index abe5dc9ee6a082548f48d7809848847495caeb9b..7a7d6af1f359d66529b12b6b36af80983b18a3a5 100644 (file)
@@ -5,7 +5,7 @@
 {% block content %}
     <h2>{% trans %}Wallabag configuration{% endtrans %}</h2>
 
-    <form action="{{ path('config') }}" method="post" {{ form_enctype(form.config) }}>
+    {{ form_start(form.config) }}
         {{ form_errors(form.config) }}
 
         <fieldset class="w500p inline">
@@ -37,7 +37,7 @@
 
     <h2>{% trans %}RSS configuration{% endtrans %}</h2>
 
-    <form action="{{ path('config') }}" method="post" {{ form_enctype(form.rss) }}>
+    {{ form_start(form.rss) }}
         {{ form_errors(form.rss) }}
 
         <fieldset class="w500p inline">
@@ -81,7 +81,7 @@
 
     <h2>{% trans %}User information{% endtrans %}</h2>
 
-    <form action="{{ path('config') }}" method="post" {{ form_enctype(form.user) }}>
+    {{ form_start(form.user) }}
         {{ form_errors(form.user) }}
 
         <fieldset class="w500p inline">
 
     <h2>{% trans %}Change your password{% endtrans %}</h2>
 
-    <form action="{{ path('config') }}" method="post" {{ form_enctype(form.pwd) }}>
+    {{ form_start(form.pwd) }}
         {{ form_errors(form.pwd) }}
 
         <fieldset class="w500p inline">
     {% if is_granted('ROLE_SUPER_ADMIN') %}
     <h2>{% trans %}Add a user{% endtrans %}</h2>
 
-    <form action="{{ path('config') }}" method="post" {{ form_enctype(form.new_user) }}>
+    {{ form_start(form.new_user) }}
         {{ form_errors(form.new_user) }}
 
         <fieldset class="w500p inline">
index ab24d4effad16536bf369f0b24a9f24be2589262..8f121a2b756c594bee8e0da6b21af560fac22e03 100644 (file)
@@ -21,9 +21,8 @@
                         </ul>
                     </div>
 
-
                     <div id="set1" class="col s12">
-                        <form action="{{ path('config') }}" method="post" {{ form_enctype(form.config) }}>
+                        {{ form_start(form.config) }}
                             {{ form_errors(form.config) }}
 
                             <div class="row">
@@ -57,9 +56,8 @@
                         </form>
                     </div>
 
-
                     <div id="set2" class="col s12">
-                        <form action="{{ path('config') }}#set2" method="post" {{ form_enctype(form.rss) }}>
+                        {{ form_start(form.rss) }}
                             {{ form_errors(form.rss) }}
 
                             <div class="row">
                         </form>
                     </div>
 
-
                     <div id="set3" class="col s12">
-                        <form action="{{ path('config') }}#set3" method="post" {{ form_enctype(form.user) }}>
+                        {{ form_start(form.user) }}
                             {{ form_errors(form.user) }}
 
                             <div class="row">
                         </form>
                     </div>
 
-
                     <div id="set4" class="col s12">
-                        <form action="{{ path('config') }}#set4" method="post" {{ form_enctype(form.pwd) }}>
+                        {{ form_start(form.pwd) }}
                             {{ form_errors(form.pwd) }}
 
                             <div class="row">
 
                     {% if is_granted('ROLE_SUPER_ADMIN') %}
                     <div id="set5" class="col s12">
-                        <form action="{{ path('config') }}#set5" method="post" {{ form_enctype(form.new_user) }}>
+                        {{ form_start(form.new_user) }}
                             {{ form_errors(form.new_user) }}
 
                             <div class="row">
index 24910e605d603f36b0dc4e432aec9eb8c18e50bd..e98dd20260ae0c32c2295a8d8f94aea97b52af5a 100644 (file)
@@ -35,19 +35,16 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the DialogHelper
-        $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
+        // We mock the QuestionHelper
+        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
             ->disableOriginalConstructor()
             ->getMock();
-        $dialog->expects($this->any())
+        $question->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test_'.uniqid('', true)));
-        $dialog->expects($this->any())
-            ->method('askConfirmation')
-            ->will($this->returnValue(true));
+            ->will($this->returnValue('yes_'.uniqid('', true)));
 
         // We override the standard helper with our mock
-        $command->getHelperSet()->set($dialog, 'dialog');
+        $command->getHelperSet()->set($question, 'question');
 
         $tester = new CommandTester($command);
         $tester->execute(array(
@@ -69,19 +66,16 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the DialogHelper
-        $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
+        // We mock the QuestionHelper
+        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
             ->disableOriginalConstructor()
             ->getMock();
-        $dialog->expects($this->any())
+        $question->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test_'.uniqid('', true)));
-        $dialog->expects($this->any())
-            ->method('askConfirmation')
-            ->will($this->returnValue(true));
+            ->will($this->returnValue('yes_'.uniqid('', true)));
 
         // We override the standard helper with our mock
-        $command->getHelperSet()->set($dialog, 'dialog');
+        $command->getHelperSet()->set($question, 'question');
 
         $tester = new CommandTester($command);
         $tester->execute(array(
@@ -119,19 +113,16 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the DialogHelper
-        $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
+        // We mock the QuestionHelper
+        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
             ->disableOriginalConstructor()
             ->getMock();
-        $dialog->expects($this->any())
+        $question->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test_'.uniqid('', true)));
-        $dialog->expects($this->any())
-            ->method('askConfirmation')
-            ->will($this->returnValue(true));
+            ->will($this->returnValue('yes_'.uniqid('', true)));
 
         // We override the standard helper with our mock
-        $command->getHelperSet()->set($dialog, 'dialog');
+        $command->getHelperSet()->set($question, 'question');
 
         $tester = new CommandTester($command);
         $tester->execute(array(
@@ -156,13 +147,13 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the DialogHelper
-        $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
+        // We mock the QuestionHelper
+        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
             ->disableOriginalConstructor()
             ->getMock();
 
-        $dialog->expects($this->exactly(3))
-            ->method('askConfirmation')
+        $question->expects($this->exactly(3))
+            ->method('ask')
             ->will($this->onConsecutiveCalls(
                 false, // don't want to reset the entire database
                 true, // do want to reset the schema
@@ -170,7 +161,7 @@ class InstallCommandTest extends WallabagCoreTestCase
             ));
 
         // We override the standard helper with our mock
-        $command->getHelperSet()->set($dialog, 'dialog');
+        $command->getHelperSet()->set($question, 'question');
 
         $tester = new CommandTester($command);
         $tester->execute(array(
@@ -216,20 +207,20 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the DialogHelper
-        $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
+        // We mock the QuestionHelper
+        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
             ->disableOriginalConstructor()
             ->getMock();
 
-        $dialog->expects($this->exactly(2))
-            ->method('askConfirmation')
+        $question->expects($this->exactly(2))
+            ->method('ask')
             ->will($this->onConsecutiveCalls(
                 false, // don't want to reset the entire database
                 false // don't want to create a new user
             ));
 
         // We override the standard helper with our mock
-        $command->getHelperSet()->set($dialog, 'dialog');
+        $command->getHelperSet()->set($question, 'question');
 
         $tester = new CommandTester($command);
         $tester->execute(array(
@@ -253,19 +244,16 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the DialogHelper
-        $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
+        // We mock the QuestionHelper
+        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
             ->disableOriginalConstructor()
             ->getMock();
-        $dialog->expects($this->any())
+        $question->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test_'.uniqid('', true)));
-        $dialog->expects($this->any())
-            ->method('askConfirmation')
-            ->will($this->returnValue(true));
+            ->will($this->returnValue('yes_'.uniqid('', true)));
 
         // We override the standard helper with our mock
-        $command->getHelperSet()->set($dialog, 'dialog');
+        $command->getHelperSet()->set($question, 'question');
 
         $tester = new CommandTester($command);
         $tester->execute(array(