GraphNavigator::DIRECTION_SERIALIZATION, 'type' => $type, 'format' => $format, 'method' => 'serializeCollection', ); $methods[] = array( 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, 'type' => $type, 'format' => $format, 'method' => 'deserializeCollection', ); } } return $methods; } public function serializeCollection(VisitorInterface $visitor, Collection $collection, array $type) { // We change the base type, and pass through possible parameters. $type['name'] = 'array'; return $visitor->visitArray($collection->toArray(), $type); } public function deserializeCollection(VisitorInterface $visitor, $data, array $type) { // See above. $type['name'] = 'array'; return new ArrayCollection($visitor->visitArray($data, $type)); } }