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;
 }
 /**
  * @param DeserializationContext $context
  * @param array                  $options
  *
  * @return DeserializationContext
  */
 protected function configureDeserializationContext(DeserializationContext $context, array $options)
 {
     if (isset($options['groups'])) {
         $context->setGroups($options['groups']);
     }
     if (isset($options['version'])) {
         $context->setVersion($options['version']);
     }
     return $context;
 }