예제 #1
0
 public function deserialize($data, $type, $format, DeserializationContext $context = null)
 {
     if (!$this->deserializationVisitors->containsKey($format)) {
         throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for deserialization.', $format));
     }
     if (null === $context) {
         $context = new DeserializationContext();
     }
     $context->initialize($format, $visitor = $this->deserializationVisitors->get($format)->get(), $this->navigator, $this->factory);
     $visitor->setNavigator($this->navigator);
     $navigatorResult = $this->navigator->accept($visitor->prepare($data), $this->typeParser->parse($type), $context);
     // This is a special case if the root is handled by a callback on the object iself.
     if (null === ($visitorResult = $visitor->getResult()) && null !== $navigatorResult) {
         return $navigatorResult;
     }
     return $visitorResult;
 }
예제 #2
0
 public function deserialize($data, $type, $format)
 {
     if (!$this->deserializationVisitors->containsKey($format)) {
         throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for deserialization.', $format));
     }
     $visitor = $this->deserializationVisitors->get($format)->get();
     $visitor->setNavigator($navigator = new GraphNavigator(GraphNavigator::DIRECTION_DESERIALIZATION, $this->factory, $format, $this->handlerRegistry, $this->objectConstructor, $this->exclusionStrategy, $this->dispatcher));
     $navigatorResult = $navigator->accept($visitor->prepare($data), $this->typeParser->parse($type), $visitor);
     // This is a special case if the root is handled by a callback on the object iself.
     if (null === ($visitorResult = $visitor->getResult()) && null !== $navigatorResult) {
         return $navigatorResult;
     }
     return $visitorResult;
 }