-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add extension point to match conditions using closure #96
Conversation
Just noticed: doctrine/collections minimal required PHP version now is 5.5 so tests should pass after rebase to current master. |
* Add comparison type implementations * Centralize the comparison at the right place * enable a new extension place to provide custom operators. * Add MatchClosure Expression
d7778a6
to
678664e
Compare
The main reason, I have not merged this PR yet is because it would maybe break in subtle way the lazy loading of the ORM. There is not way to translate a closure into a sql filter. I am trying to know if it's really blocking or not @Ocramius ? |
@mikeSimonson it is blocking - we need to (sadly) merge visitor changes in sync with the repos. That sucks, but it's a design issue we didn't think of initially. |
@mikeSimonson @Ocramius anything I can do to help merge this PR? Would you prefer if I made another PR just for the extraction in classes, without the |
this is simply impossible to implement for the ORM and ODM, so it does not fit the Doctrine project IMO |
Since this is a library that user can use as a stand alone, at least we should give them the opportunity to hook in the expression matching without having the switch case. Extracting in classes would help to do that. If a user wishes to define a criteria using a closure and do not have to bother with SQL filter, why do we forbid it? I use the collections in some projects without the ORM and ODM, and sometimes I encounter the restriction caused by name standards and object equality that would be solved by a custom expression. If we don't want to introduce the |
@yvoyer the criteria system is not meant to be extensible currently. As the system is meant to provide a way to apply criteria on persistent Doctrine collection without fully initializing them, making it extensible would imply making these extensions working for database evaluations too, which is a hard problem. so for me, even |
Closing as per @stof's review here. Meanwhile, please note that ORM 3.x will have a completely property lazy-loading mechanism that will indeed support |
This PR will give the opportunity to provide a custom entry point in the matching of objects without relying on the inner
get*
is*
format supported in theClosureExpressionVisitor::getObjectFieldValue()
.Clients will now be able to have their own mechanism (whatever the name format, with or without arguments).
This PR could potentially help close #95, #68, #62, #50, #45, #28, #27 (if we do not plan on adding a fix), since the reporters could define a callback for their use case.
I am not sure what it would mean for
PersistentCollection
in the ORM package, but at least it do not affects the pattern used to access the data for checking the value.