Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Namespaced twig syntax for views #13

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
namespace Beelab\UserBundle\Controller;

use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
Copy link
Member

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"

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -18,8 +17,7 @@ class AuthController extends AbstractController
/**
* Login form.
*
* @Route("/login", name="login")
* @Method("GET")
* @Route("/login", name="login", methods={"GET"})
*
* @param AuthorizationCheckerInterface $checker
* @param LoggerInterface $logger
Expand All @@ -42,8 +40,7 @@ public function loginAction(AuthorizationCheckerInterface $checker, LoggerInterf
/**
* Logout (implemented by Symfony security system).
*
* @Route("/logout", name="logout")
* @Method("GET")
* @Route("/logout", name="logout", methods={"GET"})
*/
public function logoutAction(): void
{
Expand All @@ -53,8 +50,7 @@ public function logoutAction(): void
/**
* Login check (implemented by Symfony security system).
*
* @Route("/login_check", name="login_check")
* @Method("POST")
* @Route("/login_check", name="login_check", methods={"POST"})
*/
public function loginCheckAction(): void
{
Expand Down
31 changes: 12 additions & 19 deletions Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand All @@ -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
{
Expand All @@ -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,
]);
Expand All @@ -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(),
]);
Expand All @@ -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
{
Expand All @@ -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(),
]);
Expand All @@ -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
{
Expand All @@ -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(),
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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(),
]);
}
Expand Down
4 changes: 1 addition & 3 deletions User/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Beelab\UserBundle\User;

use Symfony\Component\Security\Core\User\AdvancedUserInterface;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! sorry about the delay.
It's been a while, but if i recall correclty it was a deprecated call.
Feel free to refuse it if you find this contribution useless.
regards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, AdvancedUserInterface was deprecated.
Anyway, this change should be in a different PR


/**
* Interface used by UserManager and User entity.
*/
interface UserInterface extends AdvancedUserInterface
interface UserInterface extends \Symfony\Component\Security\Core\User\UserInterface
{
/**
* @return string
Expand Down