Skip to content

Instantly share code, notes, and snippets.

@pjedrzejewski
Created February 18, 2016 14:23
Show Gist options
  • Save pjedrzejewski/0eb9f6490aa134b7f565 to your computer and use it in GitHub Desktop.
Save pjedrzejewski/0eb9f6490aa134b7f565 to your computer and use it in GitHub Desktop.
Simplified cart actions
sylius_shop_add_to_cart:
path: /cart/
methods: [POST]
defaults:
_controller: sylius.controller.cart_item:createAction
_sylius:
factory:
method: createForCart
arguments:
- 'expr:service('sylius.context.cart').getCart()'
sylius_shop_remove_from_cart:
path: /cart/{id}
methods: [DELETE]
defaults:
_controller: sylius.controller.cart_item.deleteAction
_sylius:
repository:
method: findOneByCartAndId
arguments:
- 'expr:service('sylius.context.cart').getCart()'
- $id
sylius_shop_clear_cart:
path: /cart/
methods: [DELETE]
defaults:
_controller: sylius.controller.cart:deleteAction
_sylius:
repository:
method: find
arguments: ['expr:service('sylius.context.cart').getCart().getId()']
sylius_shop_cart_summary:
path: /cart/
methods: [GET, PUT, PATCH]
defaults:
_controller: sylius.controller.cart:updateAction
_sylius:
repository:
method: find
arguments: ['expr:service('sylius.context.cart').getCart().getId()']
redirect: referer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment