Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added Query Hints support to Entity form type that use query builder #8378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

tiagojsag
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets [none]
License MIT
Doc PR [will add later on]

Adds an optional "query_hints" array to be passed to "entity" form types, to be used when generating the Query object to retrieve objects from storage.

I've added a basic test, that just validates the scenario where the input type for the "query_hints" is incorrect. I wanted to add a test to validate the working scenario, but my phpunit/doctrine knowledge only goes so far, so if anyone could give me a help with it, I'd really appreciate.

@@ -39,7 +46,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
*
* @throws UnexpectedTypeException
*/
public function __construct($queryBuilder, $manager = null, $class = null)
public function __construct($queryBuilder, $manager = null, $class = null, $hints = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not array $hints = array() ?

@fabpot
Copy link
Member

fabpot commented Jul 21, 2013

@beberlei Can you please have a look at this PR? Thanks.

@tiagojsag
Copy link
Contributor Author

@Tii use can use the 'choice_list' option with a SimpleChoiceList instance populated with data fetched from a repository function. This is not an exact equivalent of what this PR achieves, and cannot be used in every situation, but it's what I've been using so far on my project.

@fabpot
Copy link
Member

fabpot commented Dec 30, 2013

What's the status of this PR?

@tiagojsag Can you finish it?
@beberlei Does it make sense for you?

@beberlei
Copy link
Contributor

beberlei commented Jan 1, 2014

I am not sure this feature is warranted. Granted you can set query hints, but then again you can also configure 1 million other things on the Query object, are we to add those as well? Setting query hints is a 10% not a 90% feature (and I would argue the percentage is even lower).

I would rather extract the QueryBuilder/Query creation into a protected method as part of this PR to make the API of ORM loader more easily extendable and then suggest/document to overwrite the loader, which is easily done in the entity type using in believe the 'loader' option.

@fabpot
Copy link
Member

fabpot commented Jan 1, 2014

@beberlei 👍

@erichard
Copy link

erichard commented Feb 4, 2014

@beberlei 👍

I think to extend the default loader closure to use a new query option. That option will be similar to the existing query_builder but take a Query or a Closure object which will be passed to a new ORMQueryLoader. In this scenario we don't have any BC break as it is just new features.

I don't know if it's the best move. It may be better to merge both use case in the ORMQueryBuilderLoader but then we will have a naming issue. We could make an ORMLoader and deprecate the old one to avoid BC break.

@fabpot
Copy link
Member

fabpot commented Mar 27, 2014

Closing as @beberlei proposal looks better. I've created a ticket about this #10551 so that it does not get lost.

@fabpot fabpot closed this Mar 27, 2014
@tiagojsag tiagojsag deleted the entity_form_type_query_hints branch March 27, 2014 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants