implement ExpressionBuilder->memberOf() method#66
implement ExpressionBuilder->memberOf() method#66mikeSimonson merged 5 commits intodoctrine:masterfrom
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.
@mikeSimonson ClosureExpressionVisitor::getObjectFieldValue may return an instance of Iterator which doesn't work with in_array.
There was a problem hiding this comment.
There was a problem hiding this comment.
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.