-
Notifications
You must be signed in to change notification settings - Fork 5
Namespaced twig syntax for views #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ | |
use Beelab\UserBundle\Event\FormEvent; | ||
use Beelab\UserBundle\Event\UserEvent; | ||
use Beelab\UserBundle\Manager\UserManagerInterface; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
|
@@ -24,8 +23,7 @@ class UserController extends AbstractController | |
/** | ||
* Lists all User entities (with possible filter). | ||
* | ||
* @Route("", name="user") | ||
* @Method("GET") | ||
* @Route("", name="user", methods={"GET"}) | ||
*/ | ||
public function indexAction(EventDispatcherInterface $dispatcher, UserManagerInterface $manager, Request $request): Response | ||
{ | ||
|
@@ -40,7 +38,7 @@ public function indexAction(EventDispatcherInterface $dispatcher, UserManagerInt | |
} | ||
$users = $manager->getList($request->query->get('page', 1), 20); | ||
|
||
return $this->render('BeelabUserBundle:User:index.html.twig', [ | ||
return $this->render('@BeelabUser/User/index.html.twig', [ | ||
'users' => $users, | ||
'form' => isset($form) ? $form->createView() : null, | ||
]); | ||
|
@@ -49,15 +47,14 @@ public function indexAction(EventDispatcherInterface $dispatcher, UserManagerInt | |
/** | ||
* Finds and displays a User entity. | ||
* | ||
* @Route("/{id}/show", name="user_show") | ||
* @Method("GET") | ||
* @Route("/{id}/show", name="user_show", methods={"GET"}) | ||
*/ | ||
public function showAction($id, UserManagerInterface $manager): Response | ||
{ | ||
$user = $manager->get($id); | ||
$deleteForm = $this->createDeleteForm($user->getId()); | ||
|
||
return $this->render('BeelabUserBundle:User:show.html.twig', [ | ||
return $this->render('@BeelabUser/User/show.html.twig', [ | ||
'user' => $user, | ||
'delete_form' => $deleteForm->createView(), | ||
]); | ||
|
@@ -66,8 +63,7 @@ public function showAction($id, UserManagerInterface $manager): Response | |
/** | ||
* Creates a new User entity. | ||
* | ||
* @Route("/new", name="user_new") | ||
* @Method({"GET", "POST"}) | ||
* @Route("/new", name="user_new", methods={"GET", "POST"}) | ||
*/ | ||
public function newAction(UserManagerInterface $manager, Request $request): Response | ||
{ | ||
|
@@ -79,7 +75,7 @@ public function newAction(UserManagerInterface $manager, Request $request): Resp | |
return $this->redirectToRoute('user_show', ['id' => $user->getId()]); | ||
} | ||
|
||
return $this->render('BeelabUserBundle:User:new.html.twig',[ | ||
return $this->render('@BeelabUser/User/new.html.twig',[ | ||
'user' => $user, | ||
'form' => $form->createView(), | ||
]); | ||
|
@@ -88,8 +84,7 @@ public function newAction(UserManagerInterface $manager, Request $request): Resp | |
/** | ||
* Edits an existing User entity. | ||
* | ||
* @Route("/{id}/edit", name="user_edit") | ||
* @Method({"GET", "PUT"}) | ||
* @Route("/{id}/edit", name="user_edit", methods={"GET", "PUT"}) | ||
*/ | ||
public function editAction($id, UserManagerInterface $manager, Request $request): Response | ||
{ | ||
|
@@ -102,7 +97,7 @@ public function editAction($id, UserManagerInterface $manager, Request $request) | |
} | ||
$deleteForm = $this->createDeleteForm($user->getId()); | ||
|
||
return $this->render('BeelabUserBundle:User:edit.html.twig',[ | ||
return $this->render('@BeelabUser/User/edit.html.twig',[ | ||
'user' => $user, | ||
'edit_form' => $editForm->createView(), | ||
'delete_form' => $deleteForm->createView(), | ||
|
@@ -112,8 +107,7 @@ public function editAction($id, UserManagerInterface $manager, Request $request) | |
/** | ||
* Deletes a User entity. | ||
* | ||
* @Route("/{id}/delete", name="user_delete") | ||
* @Method("DELETE") | ||
* @Route("/{id}/delete", name="user_delete", methods={"DELETE"}) | ||
*/ | ||
public function deleteAction($id, UserManagerInterface $manager, Request $request): Response | ||
{ | ||
|
@@ -129,8 +123,7 @@ public function deleteAction($id, UserManagerInterface $manager, Request $reques | |
/** | ||
* Change password. | ||
* | ||
* @Route("/password", name="user_password") | ||
* @Method({"GET", "POST"}) | ||
* @Route("/password", name="user_password", methods={"GET", "POST"}) | ||
*/ | ||
public function passwordAction(EventDispatcherInterface $dispatcher, UserManagerInterface $manager, Request $request, ParameterBagInterface $bag): Response | ||
{ | ||
|
@@ -143,7 +136,7 @@ public function passwordAction(EventDispatcherInterface $dispatcher, UserManager | |
return $this->redirectToRoute($bag->get('beelab_user.route')); | ||
} | ||
|
||
return $this->render('BeelabUserBundle:User:password.html.twig', [ | ||
return $this->render('@BeelabUser/User/password.html.twig', [ | ||
'form' => $form->createView(), | ||
]); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,10 @@ | |
|
||
namespace Beelab\UserBundle\User; | ||
|
||
use Symfony\Component\Security\Core\User\AdvancedUserInterface; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi! sorry about the delay. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, AdvancedUserInterface was deprecated. |
||
|
||
/** | ||
* Interface used by UserManager and User entity. | ||
*/ | ||
interface UserInterface extends AdvancedUserInterface | ||
interface UserInterface extends \Symfony\Component\Security\Core\User\UserInterface | ||
{ | ||
/** | ||
* @return string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in the wrong place and it does not respect sorting. Please move it after "use Symfony\Component\HttpFoundation\Request"