This is my environment:
I have an entity:
Object |____ id (integer) |____ foo (string) |____ configurations (collection)
The configurations property is a set of Configuration objects displayed using oneToMany . In any case, it looks like this:
Configuration |____ id (integer) |____ bar (string) |____ name (string, nullable)
I have a service to get one object :
This service is bundled, which manages the objects of many projects.
This service does not know which project is invoking it.
This service is a set of filters, event listeners, and sql queries. (something around 2K lines)
Consider what cannot / does not want to update its receiving process for what I want to do here.
I have the only action that I want to act on in my controller as follows:
$objMgr = $this->get('objectManager'); //get my service I talked before $object = $objMgr->findOneById(); //get my object return array('object' => $object);// render template
I have many themes that control the end user screen with each of them:
theme1 |____ object_details.html.twig theme2 |____ object_details.html.twig themeX |____ object_details.html.twig
These object_details.html.twig have this code for printing configurations.
{% for config in object.configurations %} {# div config.blablabla etc. #} {% endfor %}
My question is:
According to the context above, can I exclude all configurations with the name property not null?
Answer Requirements:
The answer does not allow editing twig files (I know how to do this ^^)
I want to be sure that the Configuration exception will not be detected by the doctrine and will delete this config my database on a random flash somewhere in the code.
The answer may be: "Dude, we can’t do this." In fact, I am very curious to find out if this is possible. At the moment, I have no idea.
The answer should take into account some best practices :)
Waiting for comments: why not edit twig files ?: I have a lot of topics, I want to know if this can be done once.
Why not exclude the results in your db query ?: Because I want these configurations on my other pages and projects using this getter.
+50 for a better try :)
source share