Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the admin path name variable to allow the prefix value to be changed #196

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 3 additions & 94 deletions src/Resources/config/app/routing.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,7 @@
sylius_admin_order_creation_select_order_customer:
path: /admin/orders/new/select-customer
methods: [GET]
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\SelectNewOrderCustomerAction

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

sylius_admin_order_creation_customer_create:
path: /admin/orders/new/customer/{customerEmail}/{channelCode}
methods: [GET]
options:
expose: true
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\CustomerCreationAction

sylius_admin_order_creation_order_create:
path: /admin/orders/new/{customerId}/{channelCode}
methods: [GET]
options:
expose: true
defaults:
_controller: sylius.controller.order::createAction
_sylius:
event: admin_create
section: admin
permission: true
template: '@SyliusAdminOrderCreationPlugin/Order/create.html.twig'
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createForCustomerAndChannel']
arguments: [$customerId, $channelCode]
requirements:
customerId: \d+

sylius_admin_order_creation_order_preview:
path: /admin/orders/new/{customerId}/{channelCode}/preview
methods: [POST]
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\OrderPreviewAction
_sylius:
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createForCustomerAndChannel']
arguments: [$customerId, $channelCode]

sylius_admin_order_creation_order_create_from_preview:
path: /admin/orders/new/{customerId}/{channelCode}/create-from-preview
methods: [POST]
options:
expose: true
defaults:
_controller: sylius.controller.order::createAction
_sylius:
event: admin_create
section: admin
permission: true
template: '@SyliusAdminOrderCreationPlugin/Order/preview.html.twig'
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createForCustomerAndChannel']
arguments: [$customerId, $channelCode]

sylius_admin_order_creation_order_create_back:
path: /admin/orders/edit/{customerId}/{channelCode}
methods: [POST]
options:
expose: true
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\OrderCreateAction
requirements:
customerId: \d+

sylius_admin_order_creation_reorder:
path: /admin/orders/{id}/reorder
methods: [GET]
options:
expose: true
defaults:
_controller: sylius.controller.order::createAction
_sylius:
event: admin_create
section: admin
permission: true
template: '@SyliusAdminOrderCreationPlugin/Order/create.html.twig'
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createFromExistingOrder']
arguments: ["expr:service('sylius.repository.order').find($id)"]

sylius_admin_order_creation_ajax:
prefix: admin/ajax
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/ajax.yml"
sylius_admin_order_creation:
prefix: "/%sylius_admin.path_name%"
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin.yml"
Comment on lines +3 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prefix: "/%sylius_admin.path_name%"
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin.yml"
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin.yml"
prefix: "/%sylius_admin.path_name%"


fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing-sf4.xml"
95 changes: 95 additions & 0 deletions src/Resources/config/app/routing/admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
sylius_admin_order_creation_select_order_customer:
path: /orders/new/select-customer
methods: [GET]
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\SelectNewOrderCustomerAction

sylius_admin_order_creation_customer_create:
path: /orders/new/customer/{customerEmail}/{channelCode}
methods: [GET]
options:
expose: true
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\CustomerCreationAction

sylius_admin_order_creation_order_create:
path: /orders/new/{customerId}/{channelCode}
methods: [GET]
options:
expose: true
defaults:
_controller: sylius.controller.order::createAction
_sylius:
event: admin_create
section: admin
permission: true
template: '@SyliusAdminOrderCreationPlugin/Order/create.html.twig'
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createForCustomerAndChannel']
arguments: [$customerId, $channelCode]
requirements:
customerId: \d+

sylius_admin_order_creation_order_preview:
path: /orders/new/{customerId}/{channelCode}/preview
methods: [POST]
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\OrderPreviewAction
_sylius:
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createForCustomerAndChannel']
arguments: [$customerId, $channelCode]

sylius_admin_order_creation_order_create_from_preview:
path: /orders/new/{customerId}/{channelCode}/create-from-preview
methods: [POST]
options:
expose: true
defaults:
_controller: sylius.controller.order::createAction
_sylius:
event: admin_create
section: admin
permission: true
template: '@SyliusAdminOrderCreationPlugin/Order/preview.html.twig'
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createForCustomerAndChannel']
arguments: [$customerId, $channelCode]

sylius_admin_order_creation_order_create_back:
path: /orders/edit/{customerId}/{channelCode}
methods: [POST]
options:
expose: true
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\OrderCreateAction
requirements:
customerId: \d+

sylius_admin_order_creation_reorder:
path: /orders/{id}/reorder
methods: [GET]
options:
expose: true
defaults:
_controller: sylius.controller.order::createAction
_sylius:
event: admin_create
section: admin
permission: true
template: '@SyliusAdminOrderCreationPlugin/Order/create.html.twig'
form:
type: Sylius\AdminOrderCreationPlugin\Form\Type\NewOrderType
factory:
method: ['expr:service("Sylius\\AdminOrderCreationPlugin\\Factory\\OrderFactory")', 'createFromExistingOrder']
arguments: ["expr:service('sylius.repository.order').find($id)"]

sylius_admin_order_creation_ajax:
prefix: "/ajax"
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin_ajax.yml"
Comment on lines +94 to +95
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prefix: "/ajax"
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin_ajax.yml"
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin_ajax.yml"
prefix: /ajax

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming this file, which could have been imported directly before is a sort of BC.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sylius_admin_order_creation_ajax_product_variant_by_codes:
arguments: $code

sylius_admin_order_creation_ajax_provide_available_shipping_methods:
path: /admin/orders/available-shipping-methods/{customerId}/{channelCode}/{shipmentNumber}
path: /orders/available-shipping-methods/{customerId}/{channelCode}/{shipmentNumber}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is correct change since route before this was /admin/ajax/admin/..., it's a sort of BC and should be avoided if possible.

methods: [GET]
defaults:
_controller: Sylius\AdminOrderCreationPlugin\Controller\ProvideAvailableShippingMethodsAction
Expand Down