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.

41 lines
1.2KB

  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. class SwitchMerchantController extends AbstractController
  9. {
  10. public function switchMerchant(Request $request, MerchantRepository $merchantRepository)
  11. {
  12. $form = $this->createForm(SwitchMerchantFormType::class);
  13. $form->handleRequest($request);
  14. if ($form->isSubmitted() && $form->isValid()) {
  15. $merchant = $form->get('merchant')->getData();
  16. $context = $form->get('context')->getData();
  17. if ($merchant) {
  18. $url = $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
  19. if ($context == 'admin') {
  20. $url .= 'admin';
  21. }
  22. if ($url) {
  23. return $this->redirect($url);
  24. }
  25. }
  26. }
  27. }
  28. public function visitMerchant()
  29. {
  30. }
  31. }