|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?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, MerchantRepository $merchantRepository)
- {
- $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);
- }
- }
- }
- }
-
- public function visitMerchant()
- {
-
- }
- }
|