custom/plugins/PayonePayment/src/Storefront/Controller/Account/AccountMandateController.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace PayonePayment\Storefront\Controller\Account;
  4. use PayonePayment\StoreApi\Route\AbstractMandateRoute;
  5. use PayonePayment\Storefront\Page\Mandate\AccountMandatePageLoader;
  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\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. class AccountMandateController extends StorefrontController
  13. {
  14.     private AccountMandatePageLoader $accountMandatePageLoader;
  15.     private AbstractMandateRoute $mandateRoute;
  16.     public function __construct(AccountMandatePageLoader $accountMandatePageLoaderAbstractMandateRoute $mandateRoute)
  17.     {
  18.         $this->accountMandatePageLoader $accountMandatePageLoader;
  19.         $this->mandateRoute $mandateRoute;
  20.     }
  21.     /**
  22.      * @RouteScope(scopes={"storefront"})
  23.      * @Route("/account/mandate/overview", name="frontend.account.payone.mandate.page", options={"seo": "false"}, methods={"GET"})
  24.      */
  25.     public function mandateOverview(Request $requestSalesChannelContext $context): Response
  26.     {
  27.         $page $this->accountMandatePageLoader->load($request$context);
  28.         return $this->renderStorefront('@Storefront/storefront/payone/account/mandate.html.twig', ['page' => $page]);
  29.     }
  30.     /**
  31.      * @RouteScope(scopes={"storefront"})
  32.      * @Route("/account/mandate/download", name="frontend.account.payone.mandate.download", options={"seo": "false"}, methods={"GET"})
  33.      */
  34.     public function downloadMandate(Request $requestSalesChannelContext $context): Response
  35.     {
  36.         try {
  37.             $response $this->mandateRoute->getFile($request->get('mandate'), $context);
  38.         } catch (\Throwable $exception) {
  39.             $this->addFlash('danger'$this->trans('PayonePayment.mandatePage.error'));
  40.             return $this->forwardToRoute('frontend.account.payone.mandate.page');
  41.         }
  42.         return $response;
  43.     }
  44. }