sylius_admin_promotion_coupon_index:
    path: /
    methods: [GET]
    defaults:
        _controller: sylius.controller.promotion_coupon::indexAction
        _sylius:
            template: "@SyliusAdmin/PromotionCoupon/index.html.twig"
            grid: sylius_admin_promotion_coupon
            section: admin
            permission: true
            vars:
                route:
                    parameters:
                        promotionId: $promotionId
                templates:
                    breadcrumb: "@SyliusAdmin/PromotionCoupon/Index/_breadcrumb.html.twig"
                icon: tags
                subheader: sylius.ui.manage_coupons

sylius_admin_promotion_coupon_create:
    path: /new
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.promotion_coupon::createAction
        _sylius:
            factory:
                method: createForPromotion
                arguments:
                    - expr:notFoundOnNull(service('sylius.repository.promotion').find($promotionId))
            template: "@SyliusAdmin/Crud/create.html.twig"
            grid: sylius_admin_promotion_coupon
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true
            vars:
                route:
                    parameters:
                        promotionId: $promotionId
                templates:
                    form: "@SyliusAdmin/PromotionCoupon/_form.html.twig"
                    breadcrumb: "@SyliusAdmin/PromotionCoupon/Create/_breadcrumb.html.twig"
                    header_title: "@SyliusAdmin/PromotionCoupon/Create/_headerTitle.html.twig"

sylius_admin_promotion_coupon_update:
    path: /{id}/edit
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.promotion_coupon::updateAction
        _sylius:
            template: "@SyliusAdmin/Crud/update.html.twig"
            grid: sylius_admin_promotion_coupon
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true
            vars:
                route:
                    parameters:
                        id: $id
                        promotionId: $promotionId
                templates:
                    form: "@SyliusAdmin/PromotionCoupon/_form.html.twig"
                    breadcrumb: "@SyliusAdmin/PromotionCoupon/Update/_breadcrumb.html.twig"
                subheader: sylius.ui.manage_discounts_and_promotional_campaigns

sylius_admin_promotion_coupon_generate:
    path: /generate
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.promotion_coupon::generateAction
        _sylius:
            template: "@SyliusAdmin/PromotionCoupon/generate.html.twig"
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true

sylius_admin_promotion_coupon_bulk_delete:
    path: /bulk-delete
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.promotion_coupon::bulkDeleteAction
        _sylius:
            section: admin
            redirect: referer
            permission: true
            paginate: false
            repository:
                method: findById
                arguments: [$ids]

sylius_admin_promotion_coupon_delete:
    path: /{id}
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.promotion_coupon::deleteAction
        _sylius:
            section: admin
            redirect: referer
            permission: true
