|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Merchant;
-
- use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
- use Lc\SovBundle\Doctrine\EntityManager;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\Security\Core\Security;
-
- class SwitchMerchantController extends AbstractController
- {
-
- public function switchMerchant(Request $request, Security $security, EntityManager $em)
- {
- $user = $security->getUser() ;
-
- if($user) {
- $form = $this->createForm(SwitchMerchantFormType::class);
- $form->handleRequest($request);
-
- if ($form->isSubmitted() && $form->isValid()) {
- $merchant = $form->get('merchants')->getData();
- $user->setFavoriteMerchant($merchant) ;
- $em->update($user) ;
- $em->flush() ;
-
- return $this->redirectToRoute('admin_dashboard') ;
- }
- }
- else {
-
- }
- }
- }
|