serializer = new Serializer($normalizers, $encoders); } /** * Deserializes data into the given type. * * @param mixed $data * @param string $type * @param string $format * * @return object */ public function deserialize($data, $type, $format, array $context = []) { return $this->serializer->deserialize($data, $format, $context); } /** * Serializes data in the appropriate format. * * @param mixed $data any data * @param string $format format name * @param array $context options normalizers/encoders have access to * * @return string */ public function serialize($data, $format, array $context = []) { return $this->serializer->serialize($data, $format, $context); } /** * Normalizes an object into a set of arrays/scalars. * * @param object $data object to normalize * @param string $format format the normalization result will be encoded as * @param array $context Context options for the normalizer * * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface * * @return array */ public function normalize($data, $format = null, array $context = []) { return $this->serializer->normalize($data, $format, $context); } /** * Denormalizes data back into an object of the given class. * * @param mixed $data data to restore * @param string $type the expected class to instantiate * @param string $format format the given data was extracted from * @param array $context options available to the denormalizer * * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface * * @return object */ public function denormalize($data, $type, $format = null, array $context = []) { return $this->serializer->denormalize($data, $format, $context); } }