-
-
Notifications
You must be signed in to change notification settings - Fork 53
Use the admin path name variable to allow the prefix value to be changed #196
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @delyriand, thank you for your contribution. 🙏
Since optimal solution is unavailable due BC promise and flex recipe, both Resources/config/app/routing.yml
and Resources/config/app/ajax.yml
files should be left where they are, but content can be changed.
So what do you say changing it like so,
# config/app/routing.yml
sylius_admin_order_creation:
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin.yml"
prefix: "/%sylius_admin.path_name%"
sylius_admin_order_creation_ajax:
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/ajax.yml"
and
# config/app/ajax.yml
sylius_admin_order_creation_admin_ajax:
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin/ajax.yml"
prefix: "/%sylius_admin.path_name%/ajax"
Yeah, second sylius_admin_order_creation_admin_ajax
declaration forces to add admin_ajax
to make it unique, which is correct overall name, but doesn't match existing ajax route declaration, but shouldn't introduce any issues and acceptable compromise for me.
Keeping routes at config/app/routing
instead of config/routing
is acceptable since main file config/app/routing.yml
already there and cannot be moved.
|
||
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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
prefix: "/%sylius_admin.path_name%" | ||
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin.yml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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%" |
methods: [GET] | ||
defaults: | ||
_controller: Sylius\AdminOrderCreationPlugin\Controller\SelectNewOrderCustomerAction | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix: "/ajax" | ||
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin_ajax.yml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix: "/ajax" | |
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin_ajax.yml" | |
resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing/admin_ajax.yml" | |
prefix: /ajax |
if i included these directly my routes would not end up being without the prefix and there are no further permission check build into the action handlers, resulting in exposed order creation endpoints |
@esserj You're not supposed to include those files directly. The Symfony Flex recipe will include the correct files automatically. |
@vvasiloi I disagree Isn't it a bit like saying your not support to use that class? |
@esserj Of course, you may use and customize the bundle anyway you want. In fact, one of the main ideas behind the Sylius project is to make it flexible and extensibile and to facilitate custom development. Despite that, it's inevitable that there are some common practices and expectations that the developers set. When you choose to do something that doesn't align with those, then whatever the outcome is, it's your responsibility. |
@vvasiloi fair enough, but the impact of the change is potentially so high that it would at least warrant an upgrade warning. It's also fairly trivial to maintain BC and deprecate the legacy routing files in favour of new prefixed ones to avoid exposing anyones admin only code. |
@esserj, sure, I agree. Given how old this PR is, it's likely our conversation will remain hypothetical anyway. |
@vvasiloi true. I did consider that, but rather have the information out and not need it then have unpleasant surprises |
Ref #117
and see the comment in #118 (comment)