Of course you need to modify CityType a little (create constructor where you inject your ValidateCountryCitySubscriber class and $doctrineListener property):protected $doctrineListenerpublic function __construct(ValidateCountryCitySubscriber $doctrineListener){ $this->doctrineListener = $doctrineListener;}然后在类型类中以这种方式添加订阅者:And then inside the type class you add the subscriber in that way:$builder->addEventSubscriber($this->doctrineListener); 这篇关于如何使用 symfony 2.3 在订阅者中调用实体管理器类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-16 23:05