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

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. use Throwable;
  14. class AccountCardController extends StorefrontController
  15. {
  16.     /** @var AccountCardPageLoader */
  17.     private $accountCardPageLoader;
  18.     /** @var AbstractCardRoute */
  19.     private $cardRoute;
  20.     public function __construct(AccountCardPageLoader $accountCardPageLoaderAbstractCardRoute $cardRoute)
  21.     {
  22.         $this->accountCardPageLoader $accountCardPageLoader;
  23.         $this->cardRoute             $cardRoute;
  24.     }
  25.     /**
  26.      * @RouteScope(scopes={"storefront"})
  27.      * @Route("/account/card/overview", name="frontend.account.payone.card.page", options={"seo": "false"}, methods={"GET"})
  28.      */
  29.     public function cardOverview(Request $requestSalesChannelContext $context): Response
  30.     {
  31.         $page $this->accountCardPageLoader->load($request$context);
  32.         return $this->renderStorefront('@Storefront/storefront/payone/account/card.html.twig', ['page' => $page]);
  33.     }
  34.     /**
  35.      * @RouteScope(scopes={"storefront"})
  36.      * @Route("/account/card/delete", name="frontend.account.payone.card.delete", options={"seo": "false"}, methods={"GET"})
  37.      */
  38.     public function deleteCard(Request $requestSalesChannelContext $context): Response
  39.     {
  40.         try {
  41.             $this->cardRoute->delete($request->get('pseudoCardPan'), $context);
  42.         } catch (Throwable $exception) {
  43.             $this->addFlash('danger'$this->trans('PayonePayment.cardPage.error'));
  44.             return $this->forwardToRoute('frontend.account.payone.card.page');
  45.         }
  46.         $this->addFlash('success'$this->trans('PayonePayment.cardPage.success'));
  47.         return new RedirectResponse($this->generateUrl('frontend.account.payone.card.page'));
  48.     }
  49. }