Search code examples
symfonysolarium

Inject dependencies into a custom solarium document


I'm using NelmioSolariumBundle in a project to integrate .

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 . I need to replace that reference with the correspondent label.

That's why I thought of injecting doctrine.orm.entity_manager into my 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.

How do I transform attributes of my documentclass through doctrine.orm.entity_manager?


Solution

  • the best way is factor class which uses solr and the entity-manager.

    1. get your document from solr
    2. transform the fields you want

    You can try the solr-bundle. It integrates solr-documents/indexing into doctrine.