From 4077594ba721adc43d3fa38e80d6e8585f7fdbf0 Mon Sep 17 00:00:00 2001 From: Andreas Haugstrup Pedersen Date: Thu, 24 Jan 2013 10:56:43 -0800 Subject: [PATCH] Don't try to parse body when passing in array. Fixes #7 --- lib/PodioObject.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/PodioObject.php b/lib/PodioObject.php index 653771ad..cf4efa5e 100644 --- a/lib/PodioObject.php +++ b/lib/PodioObject.php @@ -140,9 +140,14 @@ protected function set_attribute($name, $value) { throw new Exception("Attribute cannot be assigned. Property '{$name}' doesn't exist."); } - public static function listing($response) { - if ($response) { - $body = $response->json_body(); + public static function listing($response_or_attributes) { + if ($response_or_attributes) { + if (is_object($response_or_attributes) && get_class($response_or_attributes) == 'PodioResponse') { + $body = $response_or_attributes->json_body(); + } + else { + $body = $response_or_attributes; + } $list = array(); foreach ($body as $attributes) { $class_name = get_called_class();