Skip to content

Instantly share code, notes, and snippets.

@alpha1125
Last active August 8, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alpha1125/723921da68749328c751f1aae78f4d52 to your computer and use it in GitHub Desktop.
Save alpha1125/723921da68749328c751f1aae78f4d52 to your computer and use it in GitHub Desktop.
doctrine filter vs match.
<?php
$criteria = Criteria::create()->where(Criteria::expr()->eq("id", $listId));
$desiredList = $property->getLists()->matching($criteria);
## $desiredList is an empty ArrayCollection()
## The following works:
$list = $property->getLists()->filter(function (PropertyList $listResult) use ($listId) {
return ($listResult->getId() == $listId);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment