Exemple #1
1
 /**
  * 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;
 }
 /**
  * {@inheritdoc}
  */
 public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context)
 {
     if ($context->attributes->containsKey('target') && $context->getDepth() === 1) {
         return $context->attributes->get('target')->get();
     }
     return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
 }