Sylius:附加结帐步骤缺少侦听器

问题描述 投票:0回答:1

我想在sylius结帐过程中添加一个结帐步骤。从某种意义上说,这是有效的,当我进入购物车概览并单击结帐时,将显示我添加的步骤。但是,当我单击“下一步”时,出现错误“无法为命名路由“ sylius_order_index”生成URL,因为这样的路由不存在。”

到目前为止,我所做的(为避免分心,我称我的结帐步骤为“测试”:]:

config / packages / _sylius.yaml:

winzou_state_machine:
    sylius_order_checkout:
        states:
            test_selected: ~ 
        transitions:     
            select_test:
                from: [cart, test_selected, addressed, shipping_selected, shipping_skipped, payment_selected, payment_skipped]
                to: test_selected
            address:
                from: [cart, test_selected, addressed, shipping_selected, shipping_skipped, payment_selected, payment_skipped]
                to: addressed
            select_shipping:
                from: [addressed, test_selected, shipping_selected, payment_selected, payment_skipped]
                to: shipping_selected
            select_payment:
                from: [payment_selected, test_selected, shipping_skipped, shipping_selected]
                to: payment_selected           
        callbacks:
            after:
                sylius_process_cart:
                    on: ["select_shipping", "address", "select_payment", "skip_shipping", "skip_payment", "select_test"]
                    do: ["@sylius.order_processing.order_processor", "process"]
                    args: ["object"]

sylius_shop:
    product_grid:
        include_all_descendants: true
    checkout_resolver:
        route_map:
            cart:
                route: sylius_shop_checkout_test
            test_selected:
                route: sylius_shop_checkout_address

routes / Checkout / checkout.yml:

sylius_shop_checkout_start:
    path: /
    methods: [GET]
    defaults:
        _controller: FrameworkBundle:Redirect:redirect
        route: sylius_shop_checkout_test

sylius_shop_checkout_test:
    path: /test
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.order:updateAction
        _sylius:
            event: test
            flash: false
            template: "Checkout/Test/test.html.twig"
            form:
                type: App\Form\TestType
            repository:
                method: findCartForAddressing
                arguments:
                    - "expr:service('sylius.context.cart').getCart().getId()"
            state_machine:
                graph: sylius_order_checkout
                transition: select_test
#after this all other states as they are in native Sylius in this file. The original checkout.yml is completely overridden with this one.

我在MY中遵循编译器,而不是NATIVE签出步骤,不同之处在于

Bundle / Controller / ResourceController.php第311行:

    $postEventResponse = $postEvent->getResponse();
    if (null !== $postEventResponse) {
        return $postEventResponse;
    }

Response对象为null(因此,如果没有加入if,编译器将继续生成上述提到的错误/误导性错误消息)。所以我注意到发生这种情况是因为在

symfony / event-dispatcher / EventDispatcher.php第72行:

if ($listeners) {
    $this->callListeners($listeners, $eventName, $event);
}

$ listeners在我的情况下是一个空数组,而在其他本机sylius步骤中,至少有一个侦听器在此订阅。我只是不知道在哪里添加。谁能指出我的位置/方式吗?

symfony listener symfony4 checkout sylius
1个回答
1
投票

我自己解决了。 services.yaml中缺少的所有内容如下:

app.request.matcher:
    class: Symfony\Component\HttpFoundation\RequestMatcher

sylius.listener.checkout_redirect:
    class: Sylius\Bundle\CoreBundle\Checkout\CheckoutRedirectListener
    tags:
        - { name: 'kernel.event_listener', event: 'sylius.order.post_address',  method: 'handleCheckoutRedirect'}
        - { name: 'kernel.event_listener', event: 'sylius.order.post_select_shipping',  method: 'handleCheckoutRedirect'}
        - { name: 'kernel.event_listener', event: 'sylius.order.post_payment',  method: 'handleCheckoutRedirect'}
        - { name: 'kernel.event_listener', event: 'sylius.order.post_test',  method: 'handleCheckoutRedirect'}
    arguments:
        - '@request_stack'
        - '@sylius.router.checkout_state'
        - '@app.request.matcher'
© www.soinside.com 2019 - 2024. All rights reserved.