# This file is a part of the Sylius package.
# (c) Sylius Sp. z o.o.

sylius_shop_product_review_index:
    path: /
    methods: [GET]
    defaults:
        _controller: sylius.controller.product_review::indexAction
        _sylius:
            template: "@SyliusShop/product_review/index.html.twig"
            repository:
                method: findAcceptedByProductSlugAndChannel
                arguments:
                    - $slug
                    - "expr:service('sylius.context.locale').getLocaleCode()"
                    - "expr:service('sylius.context.channel').getChannel()"

sylius_shop_product_review_create:
    path: /new
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.product_review::createAction
        _sylius:
            template: "@SyliusShop/product_review/create.html.twig"
            form:
                type: Sylius\Bundle\ShopBundle\Form\Type\Product\ProductReviewType
                options:
                    validation_groups: ['sylius', 'sylius_review']
            factory:
                method: createForSubjectWithReviewer
                arguments:
                    - "expr:notFoundOnNull(service('sylius.repository.product').findOneByChannelAndSlug(service('sylius.context.channel').getChannel(), service('sylius.context.locale').getLocaleCode(), $slug))"
                    - "expr:service('sylius.context.customer').getCustomer()"
            redirect:
                route: sylius_shop_product_show
                parameters:
                    slug: $slug
            flash: sylius.review.wait_for_the_acceptation
