Skip to content

Commit

Permalink
Bumped the Symfony dependency to 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Sep 26, 2014
1 parent f492498 commit 05f7f43
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 109 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

### 2.0.0 (2014-XX-XX)

* The minimum requirement for Symfony has been bumped to 2.3 (older versions are already EOLed).
* [BC break] The ``FOSUserBundle:Security:login.html.twig`` template now receives an AuthenticationException in the ``error``
variable rather than an error message.

Expand Down
28 changes: 13 additions & 15 deletions Controller/ChangePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,25 @@ public function changePasswordAction(Request $request)
$form = $formFactory->createForm();
$form->setData($user);

if ($request->isMethod('POST')) {
$form->bind($request);
$form->handleRequest($request);

if ($form->isValid()) {
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->container->get('fos_user.user_manager');
if ($form->isValid()) {
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->container->get('fos_user.user_manager');

$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_SUCCESS, $event);
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_SUCCESS, $event);

$userManager->updateUser($user);
$userManager->updateUser($user);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_profile_show');
$response = new RedirectResponse($url);
}
if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_profile_show');
$response = new RedirectResponse($url);
}

$dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_COMPLETED, new FilterUserResponseEvent($user, $request, $response));

return $response;
}
return $response;
}

return $this->container->get('templating')->renderResponse(
Expand Down
52 changes: 24 additions & 28 deletions Controller/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,25 @@ public function editAction(Request $request, $groupName)
$form = $formFactory->createForm();
$form->setData($group);

if ($request->isMethod('POST')) {
$form->bind($request);
$form->handleRequest($request);

if ($form->isValid()) {
/** @var $groupManager \FOS\UserBundle\Model\GroupManagerInterface */
$groupManager = $this->container->get('fos_user.group_manager');
if ($form->isValid()) {
/** @var $groupManager \FOS\UserBundle\Model\GroupManagerInterface */
$groupManager = $this->container->get('fos_user.group_manager');

$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_SUCCESS, $event);
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_SUCCESS, $event);

$groupManager->updateGroup($group);
$groupManager->updateGroup($group);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_group_show', array('groupName' => $group->getName()));
$response = new RedirectResponse($url);
}
if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_group_show', array('groupName' => $group->getName()));
$response = new RedirectResponse($url);
}

$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));

return $response;
}
return $response;
}

return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:edit.html.'.$this->getEngine(), array(
Expand Down Expand Up @@ -120,24 +118,22 @@ public function newAction(Request $request)
$form = $formFactory->createForm();
$form->setData($group);

if ($request->isMethod('POST')) {
$form->bind($request);
$form->handleRequest($request);

if ($form->isValid()) {
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_CREATE_SUCCESS, $event);
if ($form->isValid()) {
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_CREATE_SUCCESS, $event);

$groupManager->updateGroup($group);
$groupManager->updateGroup($group);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_group_show', array('groupName' => $group->getName()));
$response = new RedirectResponse($url);
}
if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_group_show', array('groupName' => $group->getName()));
$response = new RedirectResponse($url);
}

$dispatcher->dispatch(FOSUserEvents::GROUP_CREATE_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
$dispatcher->dispatch(FOSUserEvents::GROUP_CREATE_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));

return $response;
}
return $response;
}

return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:new.html.'.$this->getEngine(), array(
Expand Down
28 changes: 13 additions & 15 deletions Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,25 @@ public function editAction(Request $request)
$form = $formFactory->createForm();
$form->setData($user);

if ('POST' === $request->getMethod()) {
$form->bind($request);
$form->handleRequest($request);

if ($form->isValid()) {
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->container->get('fos_user.user_manager');
if ($form->isValid()) {
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->container->get('fos_user.user_manager');

$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_SUCCESS, $event);
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_SUCCESS, $event);

$userManager->updateUser($user);
$userManager->updateUser($user);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_profile_show');
$response = new RedirectResponse($url);
}
if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_profile_show');
$response = new RedirectResponse($url);
}

$dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response));

return $response;
}
return $response;
}

return $this->container->get('templating')->renderResponse(
Expand Down
24 changes: 11 additions & 13 deletions Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,22 @@ public function registerAction(Request $request)
$form = $formFactory->createForm();
$form->setData($user);

if ('POST' === $request->getMethod()) {
$form->bind($request);
$form->handleRequest($request);

if ($form->isValid()) {
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
if ($form->isValid()) {
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);

$userManager->updateUser($user);
$userManager->updateUser($user);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
}
if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
}

$dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));

return $response;
}
return $response;
}

return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
Expand Down
24 changes: 11 additions & 13 deletions Controller/ResettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,22 @@ public function resetAction(Request $request, $token)
$form = $formFactory->createForm();
$form->setData($user);

if ('POST' === $request->getMethod()) {
$form->bind($request);
$form->handleRequest($request);

if ($form->isValid()) {
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_SUCCESS, $event);
if ($form->isValid()) {
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_SUCCESS, $event);

$userManager->updateUser($user);
$userManager->updateUser($user);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_profile_show');
$response = new RedirectResponse($url);
}
if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_profile_show');
$response = new RedirectResponse($url);
}

$dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_COMPLETED, new FilterUserResponseEvent($user, $request, $response));

return $response;
}
return $response;
}

return $this->container->get('templating')->renderResponse('FOSUserBundle:Resetting:reset.html.'.$this->getEngine(), array(
Expand Down
10 changes: 1 addition & 9 deletions Form/Type/ChangePasswordFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Security\Core\Validator\Constraint\UserPassword as OldUserPassword;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;

class ChangePasswordFormType extends AbstractType
Expand All @@ -31,18 +30,11 @@ public function __construct($class)

public function buildForm(FormBuilderInterface $builder, array $options)
{
if (class_exists('Symfony\Component\Security\Core\Validator\Constraints\UserPassword')) {
$constraint = new UserPassword();
} else {
// Symfony 2.1 support with the old constraint class
$constraint = new OldUserPassword();
}

$builder->add('current_password', 'password', array(
'label' => 'form.current_password',
'translation_domain' => 'FOSUserBundle',
'mapped' => false,
'constraints' => $constraint,
'constraints' => new UserPassword(),
));
$builder->add('plainPassword', 'repeated', array(
'type' => 'password',
Expand Down
10 changes: 1 addition & 9 deletions Form/Type/ProfileFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\Validator\Constraint\UserPassword as OldUserPassword;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;

class ProfileFormType extends AbstractType
Expand All @@ -31,20 +30,13 @@ public function __construct($class)

public function buildForm(FormBuilderInterface $builder, array $options)
{
if (class_exists('Symfony\Component\Security\Core\Validator\Constraints\UserPassword')) {
$constraint = new UserPassword();
} else {
// Symfony 2.1 support with the old constraint class
$constraint = new OldUserPassword();
}

$this->buildUserForm($builder, $options);

$builder->add('current_password', 'password', array(
'label' => 'form.current_password',
'translation_domain' => 'FOSUserBundle',
'mapped' => false,
'constraints' => $constraint,
'constraints' => new UserPassword(),
));
}

Expand Down
2 changes: 1 addition & 1 deletion Util/TokenGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace FOS\UserBundle\Util;

use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;

class TokenGenerator implements TokenGeneratorInterface
{
Expand Down
3 changes: 2 additions & 1 deletion Util/UserManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FOS\UserBundle\Util;

use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManagerInterface;

/**
Expand Down Expand Up @@ -162,7 +163,7 @@ public function removeRole($username, $role)
* Finds a user by his username and throws an exception if we can't find it.
*
* @param string $username
*
*
* @throws \InvalidArgumentException When user does not exist
*
* @return UserInterface
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
"minimum-stability": "dev",
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": "~2.1",
"symfony/form": "~2.1",
"symfony/security-bundle": "~2.1"
"symfony/framework-bundle": "~2.3",
"symfony/form": "~2.3",
"symfony/security-bundle": "~2.3"
},
"require-dev": {
"twig/twig": "~1.5",
"doctrine/doctrine-bundle": "*",
"swiftmailer/swiftmailer": ">=4.3, <6.0",
"willdurand/propel-typehintable-behavior": "dev-master",
"symfony/yaml": "~2.1",
"symfony/validator": "~2.1"
"symfony/yaml": "~2.3",
"symfony/validator": "~2.3"
},
"suggest": {
"willdurand/propel-typehintable-behavior": "Needed when using the propel implementation"
Expand Down

0 comments on commit 05f7f43

Please sign in to comment.