我可以定义在学说中调用事件侦听器/订阅者的顺序吗? [英] Can I define the order in which event listeners / subscribers are called in doctrine?
本文介绍了我可以定义在学说中调用事件侦听器/订阅者的顺序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个事件订阅者 A 和 B.都订阅了 onFlush
事件.
I have two event subscribers A and B. Both subscribed to the onFlush
event.
我想确保 a::onFlush()
总是在 B::onFlush()
之前被调用.我在文档中找不到任何相关资源.
I want to make sure that a::onFlush()
is always called before B::onFlush()
.
I can't find any resource on this in the documentation.
我使用 symfony2,所以如果我能在服务定义中传递值就好了.
I use symfony2 so it would be great if I could just pass the value in in the service definition.
推荐答案
为您的服务标签添加优先级.优先级越高,运行越早.
Add a priority to your service tag. The higher the priority the earlier it will run.
services:
my.listener:
class: AcmeSearchBundleEventListenerSearchIndexer
tags:
- { name: doctrine.event_listener, event: postPersist, priority: 100 }
这篇关于我可以定义在学说中调用事件侦听器/订阅者的顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文