Example #1
0
 public function deserializeCollection(VisitorInterface $visitor, $data, array $type, Context $context)
 {
     // See above.
     $type['name'] = 'array';
     // When there is not root set for the visitor we need to handle the vector result setting
     // manually this is related to https://github.com/schmittjoh/serializer/issues/95
     $isRoot = null === $visitor->getResult();
     if ($isRoot && $visitor instanceof GenericDeserializationVisitor) {
         $metadata = new ClassMetadata(Vector::class);
         $vector = new Vector();
         $visitor->startVisitingObject($metadata, $vector, $type, $context);
         $array = $visitor->visitArray($data, $type, $context);
         $vector->setAll($array);
         $visitor->endVisitingObject($metadata, $vector, $type, $context);
         return $vector;
     }
     // No a root so just return the vector
     return new Vector($visitor->visitArray($data, $type, $context));
 }