custom/plugins/PayonePayment/src/Storefront/Controller/Account/AccountCardController.php line 33

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace PayonePayment\Storefront\Controller\Account;
  4. use PayonePayment\StoreApi\Route\AbstractCardRoute;
  5. use PayonePayment\Storefront\Page\Card\AccountCardPageLoader;
  6. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. use Shopware\Storefront\Controller\StorefrontController;
  9. use Symfony\Component\HttpFoundation\RedirectResponse;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class AccountCardController extends StorefrontController
  14. {
  15.     private AccountCardPageLoader $accountCardPageLoader;
  16.     private AbstractCardRoute $cardRoute;
  17.     public function __construct(AccountCardPageLoader $accountCardPageLoaderAbstractCardRoute $cardRoute)
  18.     {
  19.         $this->accountCardPageLoader $accountCardPageLoader;
  20.         $this->cardRoute $cardRoute;
  21.     }
  22.     /**
  23.      * @RouteScope(scopes={"storefront"})
  24.      * @Route("/account/card/overview", name="frontend.account.payone.card.page", options={"seo": "false"}, methods={"GET"})
  25.      */
  26.     public function cardOverview(Request $requestSalesChannelContext $context): Response
  27.     {
  28.         $page $this->accountCardPageLoader->load($request$context);
  29.         return $this->renderStorefront('@Storefront/storefront/payone/account/card.html.twig', ['page' => $page]);
  30.     }
  31.     /**
  32.      * @RouteScope(scopes={"storefront"})
  33.      * @Route("/account/card/delete", name="frontend.account.payone.card.delete", options={"seo": "false"}, methods={"GET"})
  34.      */
  35.     public function deleteCard(Request $requestSalesChannelContext $context): Response
  36.     {
  37.         try {
  38.             $this->cardRoute->delete($request->get('pseudoCardPan'), $context);
  39.         } catch (\Throwable $exception) {
  40.             $this->addFlash('danger'$this->trans('PayonePayment.cardPage.error'));
  41.             return $this->forwardToRoute('frontend.account.payone.card.page');
  42.         }
  43.         $this->addFlash('success'$this->trans('PayonePayment.cardPage.success'));
  44.         return new RedirectResponse($this->generateUrl('frontend.account.payone.card.page'));
  45.     }
  46. }