Exemplo n.º 1
0
 public function serialize($data, $format, SerializationContext $context = null)
 {
     if (!$this->serializationVisitors->containsKey($format)) {
         throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for serialization.', $format));
     }
     if (null === $context) {
         $context = new SerializationContext();
     }
     $context->initialize($format, $visitor = $this->serializationVisitors->get($format)->get(), $this->navigator, $this->factory);
     $visitor->setNavigator($this->navigator);
     $this->navigator->accept($visitor->prepare($data), null, $context);
     return $visitor->getResult();
 }