/** * Build the deserialization context */ private function createContext() { $context = new DeserializationContext(); if (!empty($this->context['groups'])) { $context->setGroups($this->context['groups']); } if (!empty($this->context['version'])) { $context->setVersion((int) $this->context['version']); } if (!empty($this->context['serializeNull'])) { $context->setSerializeNull((bool) $this->context['serializeNull']); } if (!empty($this->context['enableMaxDepthChecks'])) { $context->enableMaxDepthChecks(); } if (!empty($this->context['attributes'])) { foreach ($this->context['attributes'] as $key => $value) { $context->setAttribute($key, $value); } } if (!empty($this->context['depth'])) { $contextDepth = (int) $this->context['depth']; while ($context->getDepth() < $contextDepth) { $context->increaseDepth(); } } return $context; }
/** * @param SerializerInterface $serializer */ public function __construct(SerializerInterface $serializer = null) { $this->serializer = $serializer ?: SerializerBuilder::create()->build(); $this->serializationContext = new SerializationContext(); $this->serializationContext->setSerializeNull(true); $this->deserializationContext = new DeserializationContext(); $this->deserializationContext->setSerializeNull(true); }