private function Serializer::normalizeObject

Normalizes an object into a set of arrays/scalars

Parameters

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:

Return value

array|scalar

Throws

LogicException

UnexpectedValueException

1 call to Serializer::normalizeObject()
Serializer::normalize in drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php
Normalizes an object into a set of arrays/scalars

File

drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php, line 226

Class

Serializer
Serializer serializes and deserializes data

Namespace

Symfony\Component\Serializer

Code

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));
}