我希望在我的包中设置一个事件监听器来监听订单何时设置为已完成或已退款 .
我使用此链接中的代码成功创建了一个事件侦听器:
https://github.com/Sylius/Sylius-Docs/blob/master/bundles/general/events.rst
这是我的听众代码
namespace myBundle \ EventListener;
使用Symfony \ Component \ EventDispatcher \ GenericEvent;
class SolrListener {
public function onOrderUpdate(GenericEvent $event)
{
echo "I have hooked into it !!!";
exit();
}
}
这是我的服务条目:
myBundle.listener.solr:
class: myBundle\EventListener\SolrListener
tags:
- { name: kernel.event_listener, event: sylius.orders.post_update, method: onOrderUpdate }
我的主要问题是这个事件 . 我尝试了sylius.orders.post_update和sylius.order.post_update,两者都没有拿起 .
任何指导都将非常感谢,非常感谢 .
2 回答
您还可以将侦听器附加到订单状态的状态机 . 每次进行转换时,都会调用您的监听器 .
https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/OrderBundle/Resources/config/app/state_machine.yml
我想到了 . 更新订单时,我不应该检查:
sylius.order.post_update
但实际上 :
sylius.payment.post_update
这是我正在更新的付款 .
希望能帮到那里的人