Пример #1
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws \Exception
  */
 public function __invoke(Request $request)
 {
     $user = $this->getUser();
     if (!$user) {
         throw $this->createAccessDeniedException();
     }
     $createWalletCommand = $this->createCreateWalletCommand();
     $createWalletForm = $this->walletFormFactory->createCreateForm($createWalletCommand);
     $createWalletForm->handleRequest($request);
     if (!$createWalletForm->isValid()) {
         $validationMsg = $this->getAllFormErrorMessagesAsString($createWalletForm);
         $this->addFlash('error', $this->trans('create_transaction_form.flash.invalid_form') . ' ' . $validationMsg);
     } else {
         /** @var CreateWalletCommand $createWalletCommand */
         $createWalletCommand = $createWalletForm->getData();
         $createWalletCommand->setWalletOwnerId($user->getId()->getValue());
         $createWalletCommand->setToken($user->getBlockCypherToken());
         try {
             $commandValidator = new CreateWalletCommandValidator();
             $commandValidator->validate($createWalletCommand);
             $this->commandBus->handle($createWalletCommand);
             $this->addFlash('success', $this->trans('wallet.flash.create_successfully'));
             $url = $this->router->generate('bc_app_wallet_wallet.index');
             return new RedirectResponse($url);
         } catch (\Exception $e) {
             $this->addFlash('error', $e->getMessage());
         }
     }
     return $this->renderWalletShowNew($request, $createWalletForm->createView());
 }
Пример #2
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function __invoke(Request $request)
 {
     $user = $this->getUser();
     if (!$user) {
         throw $this->createAccessDeniedException();
     }
     $createWalletCommand = $this->createCreateWalletCommand();
     $createWalletForm = $this->walletFormFactory->createCreateForm($createWalletCommand);
     $template = $this->getBaseTemplatePrefix() . ':Wallet:show_new.html';
     return $this->templating->renderResponse($template . '.' . $this->getEngine(), array_merge($this->getBasicTemplateVariables($request), array('wallet_form' => $createWalletForm->createView())));
 }