G
G
gog692016-08-24 17:28:01
symfony
gog69, 2016-08-24 17:28:01

How to override class in symphony project?

There is a bundle of bundles in the project
There is a search service that returns an array of objects of the type Some\Bundle\SearchHit
this class is not specified in yml all this bundle of bundles has use Some\Bundle\SearchHit
in the top lines of the code I need to add a new method to it. how can this be done? final task

{% for hit in results %}
    {% include hit.getLineTemplete() with { content: hit } %}
{% endfor %}

i.e. the getLineTemplete method analyzes the internal variables of the object and returns the name of the template
so I can render a list of search results, each item in its own template

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2016-08-25
@skobkin

I'm afraid that if the bundle is not originally designed to extend objects SearchHitand SearchHit is hardcoded there, as you say, you will have to completely redefine the entire service that collects them ("search service").

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question