private function Serializer::denormalizeObject

Denormalizes data back into an object of the given class

Parameters

mixed $data data to restore:

string $class the expected class to instantiate:

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 denormalization:

Return value

object

Throws

LogicException

UnexpectedValueException

1 call to Serializer::denormalizeObject()
Serializer::denormalize in drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php
Denormalizes data back into an object of the given class

File

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

Class

Serializer
Serializer serializes and deserializes data

Namespace

Symfony\Component\Serializer

Code

private function denormalizeObject($data, $class, $format = null, array $context = array()) {
  if (!$this->normalizers) {
    throw new LogicException('You must register at least one normalizer to be able to denormalize objects.');
  }
  if (isset($this->denormalizerCache[$class][$format])) {
    return $this->denormalizerCache[$class][$format]
      ->denormalize($data, $class, $format, $context);
  }
  foreach ($this->normalizers as $normalizer) {
    if ($normalizer instanceof DenormalizerInterface && $normalizer
      ->supportsDenormalization($data, $class, $format)) {
      $this->denormalizerCache[$class][$format] = $normalizer;
      return $normalizer
        ->denormalize($data, $class, $format, $context);
    }
  }
  throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
}