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:

Return value

array|scalar

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 225

Class

Serializer
Serializer serializes and deserializes data

Namespace

Symfony\Component\Serializer

Code

private function normalizeObject($object, $format = null) {
  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);
  }
  foreach ($this->normalizers as $normalizer) {
    if ($normalizer
      ->supportsNormalization($object, $format)) {
      $this->normalizerCache[$class][$format] = $normalizer;
      return $normalizer
        ->normalize($object, $format);
    }
  }
  throw new UnexpectedValueException('Could not normalize object of type ' . $class . ', no supporting normalizer found.');
}