*/ class TakeCustomerAccountController extends BaseAdminController { /** * @param int $customer_id * @return \Symfony\Component\HttpFoundation\Response * @throws \Exception */ public function takeAction($customer_id) { if (null !== $response = $this->checkAuth(array(), 'TakeCustomerAccount', AccessManager::VIEW)) { return $response; } $form = $this->createForm('take_customer_account'); try { if (null !== $customer = CustomerQuery::create()->findPk($customer_id)) { $this->validateForm($form); $this->dispatch( TakeCustomerAccountEvents::TAKE_CUSTOMER_ACCOUNT, new TakeCustomerAccountEvent($customer) ); } else { throw new \Exception($this->getTranslator()->trans( "Customer not found", [], TakeCustomerAccount::MODULE_DOMAIN )); } $this->setCurrentRouter('router.front'); return $this->generateRedirectFromRoute('customer.home', [], [], 'router.front'); } catch (RedirectException $e) { return $this->generateRedirect($e->getUrl(), $e->getCode()); } catch (\Exception $e) { $form->setErrorMessage($e->getMessage()); $this->getParserContext()->addForm($form); $this->setCurrentRouter('router.admin'); return $this->generateRedirectFromRoute( 'admin.customer.update.view', ['customer_id' => $customer_id] ); } } }