|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Merchant;
-
- use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
- use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
- use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\Routing\Annotation\Route;
-
- class SwitchMerchantController extends AbstractController
- {
- /**
- * @Route("/merchant/switch", name="carac_merchant_switch")
- */
- public function switchMerchant(Request $request)
- {
- $form = $this->createForm(SwitchMerchantFormType::class);
- $form->handleRequest($request);
-
- if ($form->isSubmitted() && $form->isValid()) {
- $merchant = $form->get('merchant')->getData();
- $context = $form->get('context')->getData();
-
- if ($merchant) {
- $url = $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
-
- if ($context == 'admin') {
- $url .= 'admin';
- }
-
- if ($url) {
- return $this->redirect($url);
- }
- }
- }
- }
-
- }
|