sylius_admin_promotion_coupon_index:
    path: /
    methods: [GET]
    defaults:
        _controller: sylius.controller.promotion_coupon::indexAction
        _sylius:
            template: "@SyliusAdmin/shared/crud/index.html.twig"
            grid: sylius_admin_promotion_coupon
            section: admin
            permission: true
            vars:
                promotion: "expr:service('sylius.repository.promotion').find($promotionId)"

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/shared/crud/create.html.twig"
            grid: sylius_admin_promotion_coupon
            form:
                type: Sylius\Bundle\AdminBundle\Form\Type\PromotionCouponType
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true
            vars:
                route:
                    parameters:
                        promotionId: $promotionId

sylius_admin_promotion_coupon_update:
    path: /{id}/edit
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.promotion_coupon::updateAction
        _sylius:
            template: "@SyliusAdmin/shared/crud/update.html.twig"
            grid: sylius_admin_promotion_coupon
            form:
                type: Sylius\Bundle\AdminBundle\Form\Type\PromotionCouponType
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true
            vars:
                route:
                    parameters:
                        id: $id
                        promotionId: $promotionId

sylius_admin_promotion_coupon_generate:
    path: /generate
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.promotion_coupon::generateAction
        _sylius:
            template: "@SyliusAdmin/promotion_coupon/generate.html.twig"
            form:
                type: Sylius\Bundle\AdminBundle\Form\Type\PromotionCouponGeneratorInstructionType
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true
            vars:
                route:
                    parameters:
                        promotionId: $promotionId

sylius_admin_promotion_coupon_bulk_delete:
    path: /bulk-delete
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.promotion_coupon::bulkDeleteAction
        _sylius:
            section: admin
            redirect:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            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:
                route: sylius_admin_promotion_coupon_index
                parameters: { promotionId: $promotionId }
            permission: true
