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

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. use Throwable;
  13. class AccountMandateController extends StorefrontController
  14. {
  15.     /** @var AccountMandatePageLoader */
  16.     private $accountMandatePageLoader;
  17.     /** @var AbstractMandateRoute */
  18.     private $mandateRoute;
  19.     public function __construct(AccountMandatePageLoader $accountMandatePageLoaderAbstractMandateRoute $mandateRoute)
  20.     {
  21.         $this->accountMandatePageLoader $accountMandatePageLoader;
  22.         $this->mandateRoute             $mandateRoute;
  23.     }
  24.     /**
  25.      * @RouteScope(scopes={"storefront"})
  26.      * @Route("/account/mandate/overview", name="frontend.account.payone.mandate.page", options={"seo": "false"}, methods={"GET"})
  27.      */
  28.     public function mandateOverview(Request $requestSalesChannelContext $context): Response
  29.     {
  30.         $page $this->accountMandatePageLoader->load($request$context);
  31.         return $this->renderStorefront('@Storefront/storefront/payone/account/mandate.html.twig', ['page' => $page]);
  32.     }
  33.     /**
  34.      * @RouteScope(scopes={"storefront"})
  35.      * @Route("/account/mandate/download", name="frontend.account.payone.mandate.download", options={"seo": "false"}, methods={"GET"})
  36.      */
  37.     public function downloadMandate(Request $requestSalesChannelContext $context): Response
  38.     {
  39.         try {
  40.             $response $this->mandateRoute->getFile($request->get('mandate'), $context);
  41.         } catch (Throwable $exception) {
  42.             $this->addFlash('danger'$this->trans('PayonePayment.mandatePage.error'));
  43.             return $this->forwardToRoute('frontend.account.payone.mandate.page');
  44.         }
  45.         return $response;
  46.     }
  47. }