Skip to content

Commit

Permalink
[Serializer] Add support for Traversable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed May 6, 2011
1 parent 7a06421 commit 919f16a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Symfony/Component/Serializer/Serializer.php
Expand Up @@ -113,6 +113,13 @@ public function normalize($data, $format = null)
}
return $data;
}
if ($data instanceof Traversable) {
$normalized = array();
foreach ($data as $key => $val) {
$normalized[$key] = $this->isStructuredType($val) ? $this->normalize($val, $format) : $val;
}
return $normalized;
}
if (is_object($data)) {
return $this->normalizeObject($data, $format);
}
Expand Down

0 comments on commit 919f16a

Please sign in to comment.