You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
955B

  1. <?php
  2. namespace Lc\ShopBundle\Controller\Admin;
  3. use Lc\ShopBundle\Context\MerchantInterface;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class MerchantController extends AdminController
  7. {
  8. public function switchMerchantAction(Request $request): RedirectResponse
  9. {
  10. $em = $this->getDoctrine()->getManager();
  11. $idMerchant = $request->request->get('id_merchant') ;
  12. $merchant = $this->getDoctrine()
  13. ->getRepository(MerchantInterface::class)
  14. ->find($idMerchant);
  15. if($merchant) {
  16. $user = $this->security->getUser() ;
  17. $user->setMerchant($merchant) ;
  18. $em->persist($user);
  19. $em->flush() ;
  20. }
  21. return $this->redirect('admin/dashboard') ;
  22. }
  23. }