createForm( SwitchMerchantFormType::class, null, array('csrf_protection' => false) ); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $merchant = $form->get('merchant')->getData(); $context = $form->get('context')->getData(); if ($merchant) { $url = $this->getSettingValue( $merchant, MerchantSettingDefinition::SETTING_URL ); if ($context == 'admin') { $url .= 'admin'; } } } if ($url) { return $this->redirect($url); } else { $this->addFlashTranslator('error', ActionDefinition::SWITCH_MERCHANT, 'Merchant'); return $this->redirect($request->headers->get('referer')); } } }