我有一个用于创建对象的工厂。
Abbruchprotokoll::class => factory(function(ContainerInterface $c){
return new Abbruchprotokoll($c->get(Request::class)->getRouterParam('stts-id'), $c->get(MySQL::class));
})工厂正在使用一个字符串和一个依赖注入(MySQL类)创建该对象。在我的Abbruchprotokoll::class中有一个inject注解:
/**
* @Inject
* @var \Smarty
*/
protected $smarty;问题是,这个注入注解没有得到解决。我想这是因为我在FactoryResolver上,没有像ObjectCreator那样的injectMethodsAndProperties()。
我可以在工厂中以其他方式使用注解吗?
发布于 2018-07-23 00:40:20
你不能在工厂中使用注解,你需要使用autowire(Abbruchprotokoll::class)。autowire()要求对类进行自动连接,这将解析注释。
https://stackoverflow.com/questions/51464244
复制相似问题