-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
implement ExpressionBuilder->memberOf() method #66
Conversation
The parameter order seems a little odd to me. I'm assuming, the value parameter comes first to make the code more readable, Also, The code fails if the nested value is an array. $collection = new ArrayCollection([
['name' => 'Bill', 'hobbies' => ['biking', 'running', 'swimming']],
['name' => 'Todd', 'hobbies' => ['video games', 'laser tag']],
['name' => 'Casey', 'hobbies' => ['tennis', 'golf', 'photography']]
]);
$criteria = Criteria::create()->where(Criteria::expr()->memberOf('photography', 'hobbies'));
$collection->matching($criteria)->toArray(); |
…ration MEMBER_OF and add tests
Thanks for your feedback. As you said I inverted the parameters in order to make it more readable because in my opinion this is the most important thing. But changing the order of the parameter takes about 2s with my IDE. I fixed my code. Unfortunatly, it is not as beautifull as the rest of the code because I can not use the in_array function. |
case Comparison::MEMBER_OF: | ||
return function ($object) use ($field, $value) { | ||
$fieldValues = ClosureExpressionVisitor::getObjectFieldValue($object, $field); | ||
foreach ($fieldValues as $fieldValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ferjul17 Why can't you use in_array here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikeSimonson ClosureExpressionVisitor::getObjectFieldValue may return an instance of Iterator which doesn't work with in_array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you prefer something like that ?
@ferjul17 Thanks |
You're welcome :) 2016-03-27 19:00 GMT+02:00 mikeSimonson notifications@github.com:
|
Hi,
The comparison MEMBER_OF was not implemented on Cretieria while it seems really easy to implement.
I implemented it and wrote the test.
I also tested it in my application.