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.

SwitchMerchantController.php 946B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Merchant;
  3. use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class SwitchMerchantController extends AbstractController
  7. {
  8. public function switchMerchant(Request $request)
  9. {
  10. $form = $this->createForm(SwitchMerchantFormType::class);
  11. $form->handleRequest($request);
  12. if ($form->isSubmitted() && $form->isValid()) {
  13. $merchant = $form->get('merchant')->getData();
  14. $context = $form->get('context')->getData();
  15. if ($merchant) {
  16. $url = $merchant->getMerchantConfig('url');
  17. if($context == 'admin') {
  18. $url .= 'admin' ;
  19. }
  20. if ($url) {
  21. return $this->redirect($url);
  22. }
  23. }
  24. }
  25. }
  26. }