選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

SwitchMerchantController.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Merchant;
  3. use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
  4. use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
  5. use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  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, MerchantRepository $merchantRepository)
  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 = $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
  23. if ($context == 'admin') {
  24. $url .= 'admin';
  25. }
  26. if ($url) {
  27. return $this->redirect($url);
  28. }
  29. }
  30. }
  31. }
  32. public function visitMerchant()
  33. {
  34. }
  35. }