1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-21 18:11:10 +00:00

Merge pull request #1510 from wallabag/v2-sf3

v2 – Fix some deprecated for Symfony3
This commit is contained in:
Nicolas Lœuillet 2015-11-07 13:39:30 +01:00
commit 4529d0f4b6
14 changed files with 199 additions and 148 deletions

View file

@ -51,7 +51,7 @@ before_script:
script: script:
- ant prepare-$DB - ant prepare-$DB
- bin/phpunit --exclude-group command-doctrine -v - SYMFONY_DEPRECATIONS_HELPER=weak bin/phpunit --exclude-group command-doctrine -v
# after_script: # after_script:
# - | # - |

View file

@ -1,10 +1,10 @@
wallabag_api: wallabag_api:
resource: "@WallabagApiBundle/Resources/config/routing.yml" resource: "@WallabagApiBundle/Resources/config/routing.yml"
prefix: / prefix: /
app: app:
resource: @WallabagCoreBundle/Controller/ resource: @WallabagCoreBundle/Controller/
type: annotation type: annotation
doc-api: doc-api:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml" resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
@ -16,10 +16,10 @@ rest :
prefix : /api prefix : /api
homepage: homepage:
pattern: "/{page}" path: "/{page}"
defaults: { _controller: WallabagCoreBundle:Entry:showUnread, page : 1 } defaults: { _controller: WallabagCoreBundle:Entry:showUnread, page : 1 }
requirements: requirements:
page: \d+ page: \d+
fos_user: fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml" resource: "@FOSUserBundle/Resources/config/routing/all.xml"

View file

@ -60,7 +60,8 @@
"require-dev": { "require-dev": {
"doctrine/doctrine-fixtures-bundle": "~2.2.0", "doctrine/doctrine-fixtures-bundle": "~2.2.0",
"sensio/generator-bundle": "~2.5", "sensio/generator-bundle": "~2.5",
"phpunit/phpunit": "~4.4" "phpunit/phpunit": "~4.4",
"symfony/phpunit-bridge": "~2.7.0"
}, },
"scripts": { "scripts": {
"post-install-cmd": [ "post-install-cmd": [

144
composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "7fb67fafde0e24c1802714a2a47da5e1", "hash": "01e7829e7ff2b39b288871661bb05e9a",
"content-hash": "372936ba75537d8422a8e63bd419c213", "content-hash": "76830bc9c2cd6f600613c9eea7c0f1b1",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -77,16 +77,16 @@
}, },
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
"version": "v1.5.0", "version": "v1.5.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/cache.git", "url": "https://github.com/doctrine/cache.git",
"reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f" "reference": "2b9cec5a5e722010cbebc91713d4c11eaa064d5e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/eb8a73619af4f1c8711e2ce482f5de3643258a1f", "url": "https://api.github.com/repos/doctrine/cache/zipball/2b9cec5a5e722010cbebc91713d4c11eaa064d5e",
"reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f", "reference": "2b9cec5a5e722010cbebc91713d4c11eaa064d5e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -143,7 +143,7 @@
"cache", "cache",
"caching" "caching"
], ],
"time": "2015-10-28 11:27:45" "time": "2015-11-02 18:35:48"
}, },
{ {
"name": "doctrine/collections", "name": "doctrine/collections",
@ -357,16 +357,16 @@
}, },
{ {
"name": "doctrine/doctrine-bundle", "name": "doctrine/doctrine-bundle",
"version": "v1.5.2", "version": "1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/DoctrineBundle.git", "url": "https://github.com/doctrine/DoctrineBundle.git",
"reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3" "reference": "a5b3ba908ba68f3e14e42762a7b940fde65ed7da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3", "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/a5b3ba908ba68f3e14e42762a7b940fde65ed7da",
"reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3", "reference": "a5b3ba908ba68f3e14e42762a7b940fde65ed7da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -431,42 +431,42 @@
"orm", "orm",
"persistence" "persistence"
], ],
"time": "2015-08-31 14:47:06" "time": "2015-11-04 21:33:02"
}, },
{ {
"name": "doctrine/doctrine-cache-bundle", "name": "doctrine/doctrine-cache-bundle",
"version": "v1.0.1", "version": "1.2.1",
"target-dir": "Doctrine/Bundle/DoctrineCacheBundle",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/DoctrineCacheBundle.git", "url": "https://github.com/doctrine/DoctrineCacheBundle.git",
"reference": "e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d" "reference": "3233bc78e222d528ca89a6a47d48d6f37888e95e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineCacheBundle/zipball/e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d", "url": "https://api.github.com/repos/doctrine/DoctrineCacheBundle/zipball/3233bc78e222d528ca89a6a47d48d6f37888e95e",
"reference": "e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d", "reference": "3233bc78e222d528ca89a6a47d48d6f37888e95e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/cache": "~1.3", "doctrine/cache": "^1.4.2",
"doctrine/inflector": "~1.0", "doctrine/inflector": "~1.0",
"php": ">=5.3.2", "php": ">=5.3.2",
"symfony/doctrine-bridge": "~2.2", "symfony/doctrine-bridge": "~2.2|~3.0",
"symfony/framework-bundle": "~2.2", "symfony/security-acl": "~2.3|~3.0"
"symfony/security": "~2.2"
}, },
"require-dev": { "require-dev": {
"instaclick/coding-standard": "~1.1", "instaclick/coding-standard": "~1.1",
"instaclick/object-calisthenics-sniffs": "dev-master", "instaclick/object-calisthenics-sniffs": "dev-master",
"instaclick/symfony2-coding-standard": "dev-remaster", "instaclick/symfony2-coding-standard": "dev-remaster",
"phpunit/phpunit": "~3.7", "phpunit/phpunit": "~4",
"satooshi/php-coveralls": "~0.6.1", "satooshi/php-coveralls": "~0.6.1",
"squizlabs/php_codesniffer": "dev-master", "squizlabs/php_codesniffer": "~1.5",
"symfony/console": "~2.2", "symfony/console": "~2.2|~3.0",
"symfony/finder": "~2.2", "symfony/finder": "~2.2|~3.0",
"symfony/validator": "~2.2", "symfony/framework-bundle": "~2.2|~3.0",
"symfony/yaml": "~2.2" "symfony/phpunit-bridge": "~2.7|~3.0",
"symfony/validator": "~2.2|~3.0",
"symfony/yaml": "~2.2|~3.0"
}, },
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
@ -475,8 +475,8 @@
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Doctrine\\Bundle\\DoctrineCacheBundle": "" "Doctrine\\Bundle\\DoctrineCacheBundle\\": ""
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -509,26 +509,26 @@
"email": "fabien@symfony.com" "email": "fabien@symfony.com"
} }
], ],
"description": "Symfony2 Bundle for Doctrine Cache", "description": "Symfony Bundle for Doctrine Cache",
"homepage": "http://www.doctrine-project.org", "homepage": "http://www.doctrine-project.org",
"keywords": [ "keywords": [
"cache", "cache",
"caching" "caching"
], ],
"time": "2014-11-28 09:43:36" "time": "2015-11-05 13:48:27"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
"version": "v1.0.1", "version": "v1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/inflector.git", "url": "https://github.com/doctrine/inflector.git",
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604" "reference": "90b2128806bfde671b6952ab8bea493942c1fdae"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604", "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae",
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604", "reference": "90b2128806bfde671b6952ab8bea493942c1fdae",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -540,7 +540,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -582,7 +582,7 @@
"singularize", "singularize",
"string" "string"
], ],
"time": "2014-12-20 21:24:13" "time": "2015-11-06 14:35:42"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
@ -1027,12 +1027,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git", "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
"reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83" "reference": "45d6f40178216a840885b4ca6d7de9e67068568a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/d5b28c367d393f9d9fbc48c4138b2a74d51c0c83", "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/45d6f40178216a840885b4ca6d7de9e67068568a",
"reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83", "reference": "45d6f40178216a840885b4ca6d7de9e67068568a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1086,7 +1086,7 @@
"keywords": [ "keywords": [
"User management" "User management"
], ],
"time": "2015-09-15 13:15:07" "time": "2015-11-03 10:24:23"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@ -3437,16 +3437,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.23.0", "version": "v1.23.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "5868cd822fd6cf626d5f805439575f9c323cee2a" "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/5868cd822fd6cf626d5f805439575f9c323cee2a", "url": "https://api.github.com/repos/twigphp/Twig/zipball/d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
"reference": "5868cd822fd6cf626d5f805439575f9c323cee2a", "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3494,7 +3494,7 @@
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2015-10-29 23:29:01" "time": "2015-11-05 12:49:06"
}, },
{ {
"name": "willdurand/hateoas", "name": "willdurand/hateoas",
@ -4713,6 +4713,58 @@
], ],
"description": "This bundle generates code for you", "description": "This bundle generates code for you",
"time": "2015-03-17 06:36:52" "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": [], "aliases": [],

View file

@ -20,6 +20,11 @@
<php> <php>
<server name="KERNEL_DIR" value="./app/" /> <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> </php>
<filter> <filter>

View file

@ -40,7 +40,7 @@ class WallabagRestController extends FOSRestController
private function validateAuthentication() 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(); throw new AccessDeniedException();
} }
} }
@ -347,7 +347,7 @@ class WallabagRestController extends FOSRestController
*/ */
private function validateUserAccess($requestUserId) private function validateUserAccess($requestUserId)
{ {
$user = $this->get('security.context')->getToken()->getUser(); $user = $this->get('security.token_storage')->getToken()->getUser();
if ($requestUserId != $user->getId()) { if ($requestUserId != $user->getId()) {
throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId()); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId());
} }

View file

@ -25,7 +25,6 @@ abstract class AbstractControllerTest extends WebTestCase
$client = static::createClient(); $client = static::createClient();
$container = $client->getContainer(); $container = $client->getContainer();
$session = $container->get('session');
/** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
$userManager = $container->get('fos_user.user_manager'); $userManager = $container->get('fos_user.user_manager');
/** @var $loginManager \FOS\UserBundle\Security\LoginManager */ /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
@ -36,9 +35,10 @@ abstract class AbstractControllerTest extends WebTestCase
$loginManager->loginUser($firewallName, $user); $loginManager->loginUser($firewallName, $user);
// save the login token into the session and put it in a cookie // save the login token into the session and put it in a cookie
$container->get('session')->set('_security_'.$firewallName, $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
serialize($container->get('security.context')->getToken()));
$container->get('session')->save(); $container->get('session')->save();
$session = $container->get('session');
$client->getCookieJar()->set(new Cookie($session->getName(), $session->getId())); $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
return $client; return $client;

View file

@ -8,6 +8,9 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\NullOutput; 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\UserBundle\Entity\User;
use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\Config;
@ -85,10 +88,11 @@ class InstallCommand extends ContainerAwareCommand
} }
$rows[] = array($label, $status, $help); $rows[] = array($label, $status, $help);
$this->getHelper('table') $table = new Table($this->defaultOutput);
$table
->setHeaders(array('Checked', 'Status', 'Recommendation')) ->setHeaders(array('Checked', 'Status', 'Recommendation'))
->setRows($rows) ->setRows($rows)
->render($this->defaultOutput); ->render();
if (!$fulfilled) { if (!$fulfilled) {
throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.'); 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; 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->defaultOutput->writeln('Droping database, creating database and schema');
$this $this
@ -141,7 +146,8 @@ class InstallCommand extends ContainerAwareCommand
->runCommand('doctrine:schema:create') ->runCommand('doctrine:schema:create')
; ;
} elseif ($this->isSchemaPresent()) { } 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->defaultOutput->writeln('Droping schema and creating schema');
$this $this
@ -160,17 +166,6 @@ class InstallCommand extends ContainerAwareCommand
$this->defaultOutput->writeln('Clearing the cache'); $this->defaultOutput->writeln('Clearing the cache');
$this->runCommand('cache:clear'); $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(''); $this->defaultOutput->writeln('');
return $this; return $this;
@ -180,9 +175,10 @@ class InstallCommand extends ContainerAwareCommand
{ {
$this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>'); $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; return $this;
} }
@ -190,9 +186,16 @@ class InstallCommand extends ContainerAwareCommand
$userManager = $this->getContainer()->get('fos_user.user_manager'); $userManager = $this->getContainer()->get('fos_user.user_manager');
$user = $userManager->createUser(); $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')); $question = new Question('Username (default: wallabag) :', 'wallabag');
$user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', '')); $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); $user->setEnabled(true);
$em->persist($user); $em->persist($user);

View file

@ -29,7 +29,7 @@ class ConfigController extends Controller
$user = $this->getUser(); $user = $this->getUser();
// handle basic config detail (this form is defined as a service) // 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); $configForm->handleRequest($request);
if ($configForm->isValid()) { if ($configForm->isValid()) {
@ -49,7 +49,7 @@ class ConfigController extends Controller
} }
// handle changing password // handle changing password
$pwdForm = $this->createForm(new ChangePasswordType()); $pwdForm = $this->createForm(new ChangePasswordType(), null, array('action' => $this->generateUrl('config').'#set4'));
$pwdForm->handleRequest($request); $pwdForm->handleRequest($request);
if ($pwdForm->isValid()) { if ($pwdForm->isValid()) {
@ -65,7 +65,10 @@ class ConfigController extends Controller
} }
// handle changing user information // 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); $userForm->handleRequest($request);
if ($userForm->isValid()) { if ($userForm->isValid()) {
@ -80,7 +83,7 @@ class ConfigController extends Controller
} }
// handle rss information // handle rss information
$rssForm = $this->createForm(new RssType(), $config); $rssForm = $this->createForm(new RssType(), $config, array('action' => $this->generateUrl('config').'#set2'));
$rssForm->handleRequest($request); $rssForm->handleRequest($request);
if ($rssForm->isValid()) { if ($rssForm->isValid()) {
@ -99,7 +102,10 @@ class ConfigController extends Controller
$newUser = $userManager->createUser(); $newUser = $userManager->createUser();
// enable created user by default // enable created user by default
$newUser->setEnabled(true); $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); $newUserForm->handleRequest($request);
if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {

View file

@ -3,7 +3,7 @@
namespace Wallabag\CoreBundle\Helper; namespace Wallabag\CoreBundle\Helper;
use Liip\ThemeBundle\Helper\DeviceDetectionInterface; 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; use Wallabag\UserBundle\Entity\User;
/** /**
@ -14,16 +14,16 @@ use Wallabag\UserBundle\Entity\User;
*/ */
class DetectActiveTheme implements DeviceDetectionInterface class DetectActiveTheme implements DeviceDetectionInterface
{ {
protected $securityContext; protected $tokenStorage;
protected $defaultTheme; protected $defaultTheme;
/** /**
* @param SecurityContextInterface $securityContext Needed to retrieve the current user * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user
* @param string $defaultTheme Default theme when user isn't logged in * @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; $this->defaultTheme = $defaultTheme;
} }
@ -42,7 +42,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
*/ */
public function getType() public function getType()
{ {
$token = $this->securityContext->getToken(); $token = $this->tokenStorage->getToken();
if (is_null($token)) { if (is_null($token)) {
return $this->defaultTheme; return $this->defaultTheme;

View file

@ -2,7 +2,7 @@ services:
wallabag_core.helper.detect_active_theme: wallabag_core.helper.detect_active_theme:
class: Wallabag\CoreBundle\Helper\DetectActiveTheme class: Wallabag\CoreBundle\Helper\DetectActiveTheme
arguments: arguments:
- @security.context - @security.token_storage
- %theme% # default theme from parameters.yml - %theme% # default theme from parameters.yml
# custom form type # custom form type

View file

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<h2>{% trans %}Wallabag configuration{% endtrans %}</h2> <h2>{% trans %}Wallabag configuration{% endtrans %}</h2>
<form action="{{ path('config') }}" method="post" {{ form_enctype(form.config) }}> {{ form_start(form.config) }}
{{ form_errors(form.config) }} {{ form_errors(form.config) }}
<fieldset class="w500p inline"> <fieldset class="w500p inline">
@ -37,7 +37,7 @@
<h2>{% trans %}RSS configuration{% endtrans %}</h2> <h2>{% trans %}RSS configuration{% endtrans %}</h2>
<form action="{{ path('config') }}" method="post" {{ form_enctype(form.rss) }}> {{ form_start(form.rss) }}
{{ form_errors(form.rss) }} {{ form_errors(form.rss) }}
<fieldset class="w500p inline"> <fieldset class="w500p inline">
@ -81,7 +81,7 @@
<h2>{% trans %}User information{% endtrans %}</h2> <h2>{% trans %}User information{% endtrans %}</h2>
<form action="{{ path('config') }}" method="post" {{ form_enctype(form.user) }}> {{ form_start(form.user) }}
{{ form_errors(form.user) }} {{ form_errors(form.user) }}
<fieldset class="w500p inline"> <fieldset class="w500p inline">
@ -115,7 +115,7 @@
<h2>{% trans %}Change your password{% endtrans %}</h2> <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) }} {{ form_errors(form.pwd) }}
<fieldset class="w500p inline"> <fieldset class="w500p inline">
@ -148,7 +148,7 @@
{% if is_granted('ROLE_SUPER_ADMIN') %} {% if is_granted('ROLE_SUPER_ADMIN') %}
<h2>{% trans %}Add a user{% endtrans %}</h2> <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) }} {{ form_errors(form.new_user) }}
<fieldset class="w500p inline"> <fieldset class="w500p inline">

View file

@ -21,9 +21,8 @@
</ul> </ul>
</div> </div>
<div id="set1" class="col s12"> <div id="set1" class="col s12">
<form action="{{ path('config') }}" method="post" {{ form_enctype(form.config) }}> {{ form_start(form.config) }}
{{ form_errors(form.config) }} {{ form_errors(form.config) }}
<div class="row"> <div class="row">
@ -57,9 +56,8 @@
</form> </form>
</div> </div>
<div id="set2" class="col s12"> <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) }} {{ form_errors(form.rss) }}
<div class="row"> <div class="row">
@ -111,9 +109,8 @@
</form> </form>
</div> </div>
<div id="set3" class="col s12"> <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) }} {{ form_errors(form.user) }}
<div class="row"> <div class="row">
@ -150,9 +147,8 @@
</form> </form>
</div> </div>
<div id="set4" class="col s12"> <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) }} {{ form_errors(form.pwd) }}
<div class="row"> <div class="row">
@ -189,7 +185,7 @@
{% if is_granted('ROLE_SUPER_ADMIN') %} {% if is_granted('ROLE_SUPER_ADMIN') %}
<div id="set5" class="col s12"> <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) }} {{ form_errors(form.new_user) }}
<div class="row"> <div class="row">

View file

@ -35,19 +35,16 @@ class InstallCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:install'); $command = $application->find('wallabag:install');
// We mock the DialogHelper // We mock the QuestionHelper
$dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$dialog->expects($this->any()) $question->expects($this->any())
->method('ask') ->method('ask')
->will($this->returnValue('test_'.uniqid('', true))); ->will($this->returnValue('yes_'.uniqid('', true)));
$dialog->expects($this->any())
->method('askConfirmation')
->will($this->returnValue(true));
// We override the standard helper with our mock // We override the standard helper with our mock
$command->getHelperSet()->set($dialog, 'dialog'); $command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(array( $tester->execute(array(
@ -69,19 +66,16 @@ class InstallCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:install'); $command = $application->find('wallabag:install');
// We mock the DialogHelper // We mock the QuestionHelper
$dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$dialog->expects($this->any()) $question->expects($this->any())
->method('ask') ->method('ask')
->will($this->returnValue('test_'.uniqid('', true))); ->will($this->returnValue('yes_'.uniqid('', true)));
$dialog->expects($this->any())
->method('askConfirmation')
->will($this->returnValue(true));
// We override the standard helper with our mock // We override the standard helper with our mock
$command->getHelperSet()->set($dialog, 'dialog'); $command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(array( $tester->execute(array(
@ -119,19 +113,16 @@ class InstallCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:install'); $command = $application->find('wallabag:install');
// We mock the DialogHelper // We mock the QuestionHelper
$dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$dialog->expects($this->any()) $question->expects($this->any())
->method('ask') ->method('ask')
->will($this->returnValue('test_'.uniqid('', true))); ->will($this->returnValue('yes_'.uniqid('', true)));
$dialog->expects($this->any())
->method('askConfirmation')
->will($this->returnValue(true));
// We override the standard helper with our mock // We override the standard helper with our mock
$command->getHelperSet()->set($dialog, 'dialog'); $command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(array( $tester->execute(array(
@ -156,13 +147,13 @@ class InstallCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:install'); $command = $application->find('wallabag:install');
// We mock the DialogHelper // We mock the QuestionHelper
$dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$dialog->expects($this->exactly(3)) $question->expects($this->exactly(3))
->method('askConfirmation') ->method('ask')
->will($this->onConsecutiveCalls( ->will($this->onConsecutiveCalls(
false, // don't want to reset the entire database false, // don't want to reset the entire database
true, // do want to reset the schema true, // do want to reset the schema
@ -170,7 +161,7 @@ class InstallCommandTest extends WallabagCoreTestCase
)); ));
// We override the standard helper with our mock // We override the standard helper with our mock
$command->getHelperSet()->set($dialog, 'dialog'); $command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(array( $tester->execute(array(
@ -216,20 +207,20 @@ class InstallCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:install'); $command = $application->find('wallabag:install');
// We mock the DialogHelper // We mock the QuestionHelper
$dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$dialog->expects($this->exactly(2)) $question->expects($this->exactly(2))
->method('askConfirmation') ->method('ask')
->will($this->onConsecutiveCalls( ->will($this->onConsecutiveCalls(
false, // don't want to reset the entire database false, // don't want to reset the entire database
false // don't want to create a new user false // don't want to create a new user
)); ));
// We override the standard helper with our mock // We override the standard helper with our mock
$command->getHelperSet()->set($dialog, 'dialog'); $command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(array( $tester->execute(array(
@ -253,19 +244,16 @@ class InstallCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:install'); $command = $application->find('wallabag:install');
// We mock the DialogHelper // We mock the QuestionHelper
$dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$dialog->expects($this->any()) $question->expects($this->any())
->method('ask') ->method('ask')
->will($this->returnValue('test_'.uniqid('', true))); ->will($this->returnValue('yes_'.uniqid('', true)));
$dialog->expects($this->any())
->method('askConfirmation')
->will($this->returnValue(true));
// We override the standard helper with our mock // We override the standard helper with our mock
$command->getHelperSet()->set($dialog, 'dialog'); $command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(array( $tester->execute(array(