Skip to content

Commit

Permalink
OP-240 added prefix to shop routes to enable translations
Browse files Browse the repository at this point in the history
  • Loading branch information
leszczuu committed Feb 29, 2024
1 parent 899ba79 commit 0e3ba87
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const setWishlistModal = () => {
const form = document.querySelector(`#${wishlistFormName}`);
const formValue = form.querySelector(`#${wishlistFormName}_name`);

const url = '/wishlists/create';
const url = document.querySelector("[data-bb-wishlist-add-url]").dataset.bbWishlistAddUrl;
const formData = new FormData(form);
const csrfToken = document.querySelector("[data-bb-csrf]").dataset.bbCsrf;

Expand Down
120 changes: 5 additions & 115 deletions src/Resources/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,115 +1,5 @@
bitbag_sylius_wishlist_plugin_shop_wishlist_list_products:
path: /wishlist
methods: [GET]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.list_wishlist_products

bitbag_sylius_wishlist_plugin_shop_wishlist_add_products:
path: /wishlist/{wishlistId}/products
methods: [POST]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_products_to_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_product:
path: /wishlist/add/{productId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_product_to_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_product:
path: /wishlist/remove/{productId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.remove_product_from_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_selected_products:
path: /wishlist/{wishlistId}/products/delete
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.remove_selected_products_from_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_product_variant:
path: /wishlist/{wishlistId}/add/variant/{variantId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_product_variant_to_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_selected_products:
path: /wishlist/{wishlistId}/products/add
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_selected_products_to_cart

bitbag_sylius_wishlist_plugin_shop_wishlsit_export_selected_products_to_csv:
path: /wishlist/{wishlistId}/csv/export
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.export_selected_products_to_csv

bitbag_sylius_wishlist_plugin_shop_wishlist_import_from_csv:
path: /wishlist/csv/import
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.import_from_csv

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_product_variant:
path: /wishlist/{wishlistId}/remove/variant/{variantId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.remove_product_variant_from_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_render_header_template:
path: /wishlist/header-template
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.render_header_template

bitbag_sylius_wishlist_plugin_shop_wishlist_export_to_pdf:
path: /wishlist/{wishlistId}/export/pdf
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.export_wishlist_to_pdf_action

bitbag_sylius_wishlist_plugin_shop_wishlist_clean:
path: /wishlist/clear/{wishlistId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.clean_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_create_new_wishlist:
path: /wishlists/create
methods: [GET, POST, DELETE]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.create_new_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_wishlist:
path: /wishlists/{id}/remove
methods: [GET, POST, DELETE]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.wishlist::deleteAction
_sylius:
csrf_protection: false
redirect:
route: bitbag_sylius_wishlist_plugin_shop_wishlist_list_wishlists

bitbag_sylius_wishlist_plugin_shop_wishlist_edit_wishlist_name:
path: /wishlists/{id}/edit
methods: [GET, PUT, POST]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.update_wishlist_name_action

bitbag_sylius_wishlist_plugin_shop_wishlist_list_wishlists:
path: /wishlists
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.list_wishlists

bitbag_sylius_wishlist_plugin_shop_wishlist_show_chosen_wishlist:
path: /wishlists/{wishlistId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.show_chosen_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_product_to_selected_wishlist:
path: /wishlist/{wishlistId}/add/{productId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_product_to_selected_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_copy_selected_products_to_other_wishlist:
path: /wishlists/{wishlistId}/copy/{destinedWishlistId}
methods: [ POST ]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.copy_selected_products_to_other_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_wishlist_to_user:
path: /wishlists/{id}/save-wishlist
methods: [GET, PUT, POST]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_wishlists_to_user
bitbag_sylius_wishlist_plugin_shop:
resource: "@BitBagSyliusWishlistPlugin/Resources/config/routing/shop.yml"
prefix: /{_locale}
requirements:
_locale: ^[a-z]{2}(?:_[A-Z]{2})?$
115 changes: 115 additions & 0 deletions src/Resources/config/routing/shop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
bitbag_sylius_wishlist_plugin_shop_wishlist_list_products:
path: /wishlist
methods: [GET]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.list_wishlist_products

bitbag_sylius_wishlist_plugin_shop_wishlist_add_products:
path: /wishlist/{wishlistId}/products
methods: [POST]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_products_to_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_product:
path: /wishlist/add/{productId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_product_to_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_product:
path: /wishlist/remove/{productId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.remove_product_from_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_selected_products:
path: /wishlist/{wishlistId}/products/delete
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.remove_selected_products_from_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_product_variant:
path: /wishlist/{wishlistId}/add/variant/{variantId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_product_variant_to_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_selected_products:
path: /wishlist/{wishlistId}/products/add
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_selected_products_to_cart

bitbag_sylius_wishlist_plugin_shop_wishlsit_export_selected_products_to_csv:
path: /wishlist/{wishlistId}/csv/export
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.export_selected_products_to_csv

bitbag_sylius_wishlist_plugin_shop_wishlist_import_from_csv:
path: /wishlist/csv/import
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.import_from_csv

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_product_variant:
path: /wishlist/{wishlistId}/remove/variant/{variantId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.remove_product_variant_from_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_render_header_template:
path: /wishlist/header-template
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.render_header_template

bitbag_sylius_wishlist_plugin_shop_wishlist_export_to_pdf:
path: /wishlist/{wishlistId}/export/pdf
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.export_wishlist_to_pdf_action

bitbag_sylius_wishlist_plugin_shop_wishlist_clean:
path: /wishlist/clear/{wishlistId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.clean_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_create_new_wishlist:
path: /wishlists/create
methods: [GET, POST, DELETE]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.create_new_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_remove_wishlist:
path: /wishlists/{id}/remove
methods: [GET, POST, DELETE]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.wishlist::deleteAction
_sylius:
csrf_protection: false
redirect:
route: bitbag_sylius_wishlist_plugin_shop_wishlist_list_wishlists

bitbag_sylius_wishlist_plugin_shop_wishlist_edit_wishlist_name:
path: /wishlists/{id}/edit
methods: [GET, PUT, POST]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.update_wishlist_name_action

bitbag_sylius_wishlist_plugin_shop_wishlist_list_wishlists:
path: /wishlists
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.list_wishlists

bitbag_sylius_wishlist_plugin_shop_wishlist_show_chosen_wishlist:
path: /wishlists/{wishlistId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.show_chosen_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_product_to_selected_wishlist:
path: /wishlist/{wishlistId}/add/{productId}
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_product_to_selected_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_copy_selected_products_to_other_wishlist:
path: /wishlists/{wishlistId}/copy/{destinedWishlistId}
methods: [ POST ]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.copy_selected_products_to_other_wishlist

bitbag_sylius_wishlist_plugin_shop_wishlist_add_wishlist_to_user:
path: /wishlists/{id}/save-wishlist
methods: [GET, PUT, POST]
defaults:
_controller: bitbag_sylius_wishlist_plugin.controller.action.add_wishlists_to_user
2 changes: 1 addition & 1 deletion src/Resources/views/WishlistDetails/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% if wishlists|length > 1 %}
{% else %}
<div class="middle aligned column">
<button id="create_new_wishlist_button" class="ui right floated primary button" data-bb-wishlist-add="add-another-wishlist">
<button id="create_new_wishlist_button" class="ui right floated primary button" data-bb-wishlist-add="add-another-wishlist" data-bb-wishlist-add-url="{{ path('bitbag_sylius_wishlist_plugin_shop_wishlist_create_new_wishlist') }}">
{{ 'bitbag_sylius_wishlist_plugin.ui.add_another_wishlist'|trans }}
</button>
<input type="hidden" data-bb-csrf="{{ csrf_token('some-name') }}"/>
Expand Down

0 comments on commit 0e3ba87

Please sign in to comment.