From 34659c81b31109a8c660f87ed061c0200733c21d Mon Sep 17 00:00:00 2001 From: Mathew Davies Date: Thu, 19 Jul 2012 11:36:50 +0100 Subject: [PATCH] Allow the eager loader to take an array of models as well as a collection. --- classes/TheCure/Optimisers/EagerLoader.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/classes/TheCure/Optimisers/EagerLoader.php b/classes/TheCure/Optimisers/EagerLoader.php index 8d6ff8d..7b4a080 100644 --- a/classes/TheCure/Optimisers/EagerLoader.php +++ b/classes/TheCure/Optimisers/EagerLoader.php @@ -80,7 +80,7 @@ private function appendRelationAndIDs( } private function getRelationshipsAndIDsFromCollection( - ModelCollection $collection) + \TheCure\Collections\Collection $collection) { $attributes = array(); $accessor = new TransferObjectAccessor; @@ -142,9 +142,15 @@ private function getRelationshipsAndIDsFromCollection( */ public function loadRelations( Container $container, - ModelCollection $collection, + $collection, array $relationNames = array()) { + + if (is_array($collection)) + { + $collection = new \TheCure\Collections\Collection($collection); + } + $ids = $this->getRelationshipsAndIDsFromCollection($collection); $eagerLoaded = array();