Symfony2 when listeners are preferable than services?

前端 未结 1 634
梦毁少年i
梦毁少年i 2021-01-25 08:00

I know, that in most cases services preferable, because they are initiated directly at the call site and this approach making code more clear.

While harder to reason, wh

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 08:42

    Listeners make sense when you create a reusable bundle/component that should not be modified by its clients but still be extensible.

    Listeners don't make much sense for application code because they add a level of indirection that makes it harder to figure out what's going on.

    0 讨论(0)
提交回复
热议问题