dpik71879 2017-06-23 08:38
浏览 57
已采纳

在AppBundleB中注册服务时,在AppBundleA中触发事件观察器

SHORT

I have an Event Observer that is triggered in AppBundleA. Even though I've registered the service in AppBundleB. Is this how services work? This is my first time using them.

LONG

I'm trying to implement the Before/After filters in my Symfony(v2.8) app using Event Subscribers:

According to the example, I've registered the service globally in:

app/config/services.yml

The service worked and triggered correctly.

Next, I wanted to localize the service to a particular bundle so I moved the service registration to AppBundleB.

# AppBundleB\Resources\config\services.yml
services:
    app.tokens.action_subscriber:
        class: AppBundle\EventSubscriber\TokenSubscriber
        arguments: ['%tokens%']
        tags:
            - { name: kernel.event_subscriber }

However, when I ran a controller function in AppBundleA, it triggered the service above.

I don't believe this is supposed to happen. Does anyone have any ideas? Let me know if you need any other information.

Symfony v2.8

  • 写回答

1条回答 默认 最新

  • douduan5086 2017-10-26 01:43
    关注

    As far as I can tell services are triggered no matter where you place them.

    This seems to be the way it was intended. Closing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据