|
12345678910111213141516171819202122232425262728293031 |
- <?php
-
- namespace Lc\ShopBundle\Controller\Admin;
-
- use Lc\ShopBundle\Context\MerchantInterface;
- use Symfony\Component\HttpFoundation\RedirectResponse;
- use Symfony\Component\HttpFoundation\Request;
-
- class MerchantController extends AdminController
- {
-
- public function switchMerchantAction(Request $request): RedirectResponse
- {
- $em = $this->getDoctrine()->getManager();
- $idMerchant = $request->request->get('id_merchant') ;
- $merchant = $this->getDoctrine()
- ->getRepository(MerchantInterface::class)
- ->find($idMerchant);
-
- if($merchant) {
- $user = $this->security->getUser() ;
- $user->setMerchant($merchant) ;
- $em->persist($user);
- $em->flush() ;
- }
-
- return $this->redirect('admin/dashboard') ;
- }
-
- }
-
|