X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FUserBundle%2FController%2FManageController.php;h=a9746fb47d1ecc5c431e9b58862081c5bbe44a92;hb=e673b54f702f274a087e4feff409663d9636e57b;hp=1c5c86d45501f41c987edba0efa48bf320f3fa93;hpb=b5b6877976bc32f23e51c2fb0f3f973f0d571b10;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index 1c5c86d4..a9746fb4 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -7,10 +7,9 @@ use FOS\UserBundle\FOSUserEvents; use Pagerfanta\Adapter\DoctrineORMAdapter; use Pagerfanta\Exception\OutOfRangeCurrentPageException; use Pagerfanta\Pagerfanta; -use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Form\SearchUserType; @@ -22,8 +21,7 @@ class ManageController extends Controller /** * Creates a new User entity. * - * @Route("/new", name="user_new") - * @Method({"GET", "POST"}) + * @Route("/new", name="user_new", methods={"GET", "POST"}) */ public function newAction(Request $request) { @@ -33,9 +31,7 @@ class ManageController extends Controller // enable created user by default $user->setEnabled(true); - $form = $this->createForm('Wallabag\UserBundle\Form\NewUserType', $user, [ - 'validation_groups' => ['Profile'], - ]); + $form = $this->createForm('Wallabag\UserBundle\Form\NewUserType', $user); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -50,20 +46,19 @@ class ManageController extends Controller $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()]) ); - return $this->redirectToRoute('user_edit', array('id' => $user->getId())); + return $this->redirectToRoute('user_edit', ['id' => $user->getId()]); } - return $this->render('WallabagUserBundle:Manage:new.html.twig', array( + return $this->render('WallabagUserBundle:Manage:new.html.twig', [ 'user' => $user, 'form' => $form->createView(), - )); + ]); } /** * Displays a form to edit an existing User entity. * - * @Route("/{id}/edit", name="user_edit") - * @Method({"GET", "POST"}) + * @Route("/{id}/edit", name="user_edit", methods={"GET", "POST"}) */ public function editAction(Request $request, User $user) { @@ -81,22 +76,21 @@ class ManageController extends Controller $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()]) ); - return $this->redirectToRoute('user_edit', array('id' => $user->getId())); + return $this->redirectToRoute('user_edit', ['id' => $user->getId()]); } - return $this->render('WallabagUserBundle:Manage:edit.html.twig', array( + return $this->render('WallabagUserBundle:Manage:edit.html.twig', [ 'user' => $user, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), 'twofactor_auth' => $this->getParameter('twofactor_auth'), - )); + ]); } /** * Deletes a User entity. * - * @Route("/{id}", name="user_delete") - * @Method("DELETE") + * @Route("/{id}", name="user_delete", methods={"DELETE"}) */ public function deleteAction(Request $request, User $user) { @@ -117,22 +111,6 @@ class ManageController extends Controller return $this->redirectToRoute('user_index'); } - /** - * Creates a form to delete a User entity. - * - * @param User $user The User entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createDeleteForm(User $user) - { - return $this->createFormBuilder() - ->setAction($this->generateUrl('user_delete', array('id' => $user->getId()))) - ->setMethod('DELETE') - ->getForm() - ; - } - /** * @param Request $request * @param int $page @@ -177,4 +155,20 @@ class ManageController extends Controller 'users' => $pagerFanta, ]); } + + /** + * Creates a form to delete a User entity. + * + * @param User $user The User entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(User $user) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('user_delete', ['id' => $user->getId()])) + ->setMethod('DELETE') + ->getForm() + ; + } }