sylius_admin_product_variant_index:
    path: /
    methods: [GET]
    defaults:
        _controller: sylius.controller.product_variant::indexAction
        _sylius:
            template: "@SyliusAdmin/ProductVariant/index.html.twig"
            grid: sylius_admin_product_variant
            section: admin
            permission: true
            vars:
                route:
                    parameters:
                        productId: $productId
                templates:
                    breadcrumb: "@SyliusAdmin/ProductVariant/Index/_breadcrumb.html.twig"
                icon: cubes
                subheader: sylius.ui.manage_variants

sylius_admin_product_variant_create:
    path: /new
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.product_variant::createAction
        _sylius:
            factory:
                method: createForProduct
                arguments:
                    - expr:notFoundOnNull(service('sylius.repository.product').find($productId))
            template: "@SyliusAdmin/Crud/create.html.twig"
            grid: sylius_admin_product_variant
            section: admin
            redirect:
                route: sylius_admin_product_variant_index
                parameters: { productId: $productId }
            permission: true
            vars:
                route:
                    parameters:
                        productId: $productId
                templates:
                    form: "@SyliusAdmin/ProductVariant/_form.html.twig"
                    breadcrumb: "@SyliusAdmin/ProductVariant/Create/_breadcrumb.html.twig"
                    header_title: "@SyliusAdmin/ProductVariant/Create/_headerTitle.html.twig"

sylius_admin_product_variant_update:
    path: /{id}/edit
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.product_variant::updateAction
        _sylius:
            template: "@SyliusAdmin/Crud/update.html.twig"
            grid: sylius_admin_product_variant
            section: admin
            redirect:
                route: sylius_admin_product_variant_index
                parameters: { productId: $productId }
            permission: true
            repository:
                method: findOneByIdAndProductId
                arguments:
                    id: $id
                    productId: $productId
            vars:
                route:
                    parameters:
                        id: $id
                        productId: $productId
                templates:
                    form: "@SyliusAdmin/ProductVariant/_form.html.twig"
                    breadcrumb: "@SyliusAdmin/ProductVariant/Update/_breadcrumb.html.twig"
                    toolbar: "@SyliusAdmin/ProductVariant/Update/_toolbar.html.twig"

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

sylius_admin_product_variant_delete:
    path: /{id}
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.product_variant::deleteAction
        _sylius:
            section: admin
            redirect: referer
            permission: true
            repository:
                method: findOneByIdAndProductId
                arguments:
                    id: $id
                    productId: $productId

sylius_admin_product_variant_generate:
    path: /generate
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.product::updateAction
        _sylius:
            template: "@SyliusAdmin/ProductVariant/generate.html.twig"
            section: admin
            permission: true
            redirect:
                route: sylius_admin_product_variant_index
                parameters: { productId: $productId }
            form:
                type: Sylius\Bundle\ProductBundle\Form\Type\ProductGenerateVariantsType
            repository:
                method: find
                arguments: [$productId]
            flash: sylius.product_variant.generate
