From 669a01870bc761d6975a67b914a9c15920ca3e5b Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 5 Aug 2024 11:25:37 +0200 Subject: [PATCH] Routes refactor --- config/shop_ajax_routing.php | 13 +++++++++++++ config/shop_routing.php | 10 +--------- tests/Application/config/routes.yaml | 5 ----- .../routes/webgriffe_sylius_klarna_plugin.yaml | 11 +++++++++++ 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 config/shop_ajax_routing.php create mode 100644 tests/Application/config/routes/webgriffe_sylius_klarna_plugin.yaml diff --git a/config/shop_ajax_routing.php b/config/shop_ajax_routing.php new file mode 100644 index 0000000..00cbd50 --- /dev/null +++ b/config/shop_ajax_routing.php @@ -0,0 +1,13 @@ +add('webgriffe_sylius_klarna_plugin_payment_status', '/payment/{paymentId}/klarna-status') + ->controller(['webgriffe_sylius_klarna.controller.payment', 'statusAction']) + ->methods(['GET']) + ->requirements(['paymentId' => '\d+']) + ; +}; diff --git a/config/shop_routing.php b/config/shop_routing.php index d0e1c3a..965bd50 100644 --- a/config/shop_routing.php +++ b/config/shop_routing.php @@ -5,16 +5,8 @@ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return static function (RoutingConfigurator $routes): void { - $routes->import('@PayumBundle/Resources/config/routing/cancel.xml'); - - $routes->add('webgriffe_sylius_klarna_plugin_payment_process', '/order/{tokenValue}/payment/process') + $routes->add('webgriffe_sylius_klarna_plugin_payment_process', '/order/{tokenValue}/payment/klarna-process') ->controller(['webgriffe_sylius_klarna.controller.payment', 'processAction']) ->methods(['GET']) ; - - $routes->add('webgriffe_sylius_klarna_plugin_payment_status', '/payment/{paymentId}/status') - ->controller(['webgriffe_sylius_klarna.controller.payment', 'statusAction']) - ->methods(['GET']) - ->requirements(['paymentId' => '\d+']) - ; }; diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml index 633e0d5..e69de29 100644 --- a/tests/Application/config/routes.yaml +++ b/tests/Application/config/routes.yaml @@ -1,5 +0,0 @@ -webgriffe_sylius_klarna_shop: - resource: "@WebgriffeSyliusKlarnaPlugin/config/shop_routing.php" - prefix: /{_locale} - requirements: - _locale: ^[a-z]{2}(?:_[A-Z]{2})?$ diff --git a/tests/Application/config/routes/webgriffe_sylius_klarna_plugin.yaml b/tests/Application/config/routes/webgriffe_sylius_klarna_plugin.yaml new file mode 100644 index 0000000..b2c943e --- /dev/null +++ b/tests/Application/config/routes/webgriffe_sylius_klarna_plugin.yaml @@ -0,0 +1,11 @@ +webgriffe_sylius_klarna_shop: + resource: "@WebgriffeSyliusKlarnaPlugin/config/shop_routing.php" + prefix: /{_locale} + requirements: + _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ + +webgriffe_sylius_klarna_plugin_ajax: + resource: "@WebgriffeSyliusKlarnaPlugin/config/shop_ajax_routing.php" + +sylius_shop_payum_cancel: + resource: "@PayumBundle/Resources/config/routing/cancel.xml"