Created
April 16, 2014 13:01
-
-
Save AhmedSamy/10870928 to your computer and use it in GitHub Desktop.
Sorting embeded collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSortedIngredients() | |
{ | |
//workaround to sort ingredients by quantities collection | |
$iterator = $this->ingredients->getIterator(); | |
$iterator->uasort( | |
function ($a, $b) { | |
return ($a->getQuantity() > $b->getQuantity()) ? -1 : 1; | |
} | |
); | |
$ingredients = new ArrayCollection(iterator_to_array($iterator)); | |
$this->ingredients = $ingredients; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment