Normalizes an object into a set of arrays/scalars
object $object object to normalize:
string $format format name, present to give the option to normalizers to act differently based on formats:
array $context The context data for this particular normalization:
array|scalar
private function normalizeObject($object, $format = null, array $context = array()) {
if (!$this->normalizers) {
throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
}
$class = get_class($object);
if (isset($this->normalizerCache[$class][$format])) {
return $this->normalizerCache[$class][$format]
->normalize($object, $format, $context);
}
foreach ($this->normalizers as $normalizer) {
if ($normalizer instanceof NormalizerInterface && $normalizer
->supportsNormalization($object, $format)) {
$this->normalizerCache[$class][$format] = $normalizer;
return $normalizer
->normalize($object, $format, $context);
}
}
throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', $class));
}