[英]Inject dependencies into a custom solarium document
I'm using NelmioSolariumBundle in a symfony project to integrate solarium . 我在一个symfony项目中使用NelmioSolariumBundle来集成日光浴室 。
My controller 我的控制器
$query = $this->client->createSelect(array(
'documentclass' => 'MY\SolariumDocument'
));
In my custom documentclass
, I have a field that store a reference of the category of the document retrived from solr . 在我的自定义documentclass
,我有一个字段,用于存储对从solr检索的文档类别的引用。 I need to replace that reference with the correspondent label. 我需要用相应的标签替换该引用。
That's why I thought of injecting doctrine.orm.entity_manager
into my documentclass
. 这就是为什么我想到将doctrine.orm.entity_manager
注入到我的documentclass
。 I turned it into a service and through a setter I injected the entity manager but it didn't work getRepository on non-object
which makes sense because that transformation is made in the constructor. 我将其转换为服务,并通过设置器注入了实体管理器,但它对getRepository on non-object
这是有意义的,因为该转换是在构造函数中进行的。
How do I transform attributes of my documentclass
through doctrine.orm.entity_manager
? 如何通过doctrine.orm.entity_manager
转换documentclass
属性?
the best way is factor class which uses solr and the entity-manager. 最好的方法是使用solr和entity-manager的因子类。
You can try the solr-bundle . 您可以尝试solr-bundle 。 It integrates solr-documents/indexing into doctrine. 它将solr-documents / indexing集成到理论中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.