您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

44 行
1.4KB

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