Esempio n. 1
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws \Exception
  */
 public function __invoke(Request $request)
 {
     $walletId = $request->get('walletId');
     $walletDto = $this->walletServiceFacade->getWallet($walletId);
     $this->checkAuthorizationForWallet($walletDto);
     $createAddressCommand = $this->createCreateAddressCommand($walletId);
     $createAddressForm = $this->addressFormFactory->createCreateForm($createAddressCommand);
     $createAddressForm->handleRequest($request);
     if (!$createAddressForm->isValid()) {
         $validationMsg = $this->getAllFormErrorMessagesAsString($createAddressForm);
         $this->addFlash('error', $this->trans('create_address_form.flash.invalid_form') . ' ' . $validationMsg);
     } else {
         /** @var CreateAddressCommand $createAddressCommand */
         $createAddressCommand = $createAddressForm->getData();
         try {
             $commandValidator = new CreateAddressCommandValidator();
             $commandValidator->validate($createAddressCommand);
             $this->commandBus->handle($createAddressCommand);
             $this->addFlash('success', $this->trans('address.flash.create_successfully'));
             $url = $this->router->generate('bc_app_wallet_address.index', array('walletId' => $createAddressCommand->getWalletId()));
             return new RedirectResponse($url);
         } catch (\Exception $e) {
             $this->addFlash('error', $e->getMessage());
         }
     }
     $walletDto = $this->walletServiceFacade->getWallet($walletId);
     return $this->renderAddressShowNew($request, $createAddressForm->createView(), $walletDto);
 }
Esempio n. 2
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function __invoke(Request $request)
 {
     $walletId = $request->get('walletId');
     $walletDto = $this->walletServiceFacade->getWallet($walletId);
     $this->checkAuthorizationForWallet($walletDto);
     $createAddressCommand = $this->createCreateAddressCommand($walletId);
     $createAddressForm = $this->addressFormFactory->createCreateForm($createAddressCommand, $walletId);
     $template = $this->getBaseTemplatePrefix() . ':Address:show_new.html';
     return $this->templating->renderResponse($template . '.' . $this->getEngine(), array_merge($this->getBasicTemplateVariables($request), array('address_form' => $createAddressForm->createView(), 'wallet' => $walletDto)));
 }