Serializes data in the appropriate format
mixed $data any data:
string $format format name:
array $context options normalizers/encoders have access to:
string
Overrides SerializerInterface::serialize
public final function serialize($data, $format, array $context = array()) {
if (!$this
->supportsEncoding($format)) {
throw new UnexpectedValueException(sprintf('Serialization for the format %s is not supported', $format));
}
if ($this->encoder
->needsNormalization($format)) {
$data = $this
->normalize($data, $format, $context);
}
return $this
->encode($data, $format, $context);
}