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 1.3KB

3 년 전
3 년 전
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Merchant;
  3. use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
  4. use Lc\CaracoleBundle\Controller\AbstractController;
  5. use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
  6. use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class SwitchMerchantController extends AbstractController
  10. {
  11. /**
  12. * @Route("/merchant/switch", name="carac_merchant_switch")
  13. */
  14. public function switchMerchant(Request $request)
  15. {
  16. $form = $this->createForm(SwitchMerchantFormType::class);
  17. $form->handleRequest($request);
  18. if ($form->isSubmitted() && $form->isValid()) {
  19. $merchant = $form->get('merchant')->getData();
  20. $context = $form->get('context')->getData();
  21. if ($merchant) {
  22. $url = $this->getSettingValue(
  23. $merchant,
  24. MerchantSettingDefinition::SETTING_URL
  25. );
  26. if ($context == 'admin') {
  27. $url .= 'admin';
  28. }
  29. if ($url) {
  30. return $this->redirect($url);
  31. }
  32. }
  33. }
  34. }
  35. }