|
@@ -187,68 +187,68 @@ class Serializer implements SerializerInterface
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function addNormalizer(NormalizerInterface $normalizer)
|
|
|
|
|
|
+ public function supportsSerialization($format)
|
|
{
|
|
{
|
|
- $this->normalizers[] = $normalizer;
|
|
|
|
- if ($normalizer instanceof SerializerAwareInterface) {
|
|
|
|
- $normalizer->setSerializer($this);
|
|
|
|
- }
|
|
|
|
|
|
+ return isset($this->encoders[$format]);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function removeNormalizer(NormalizerInterface $normalizer)
|
|
|
|
|
|
+ public function supportsDeserialization($format)
|
|
{
|
|
{
|
|
- unset($this->normalizers[array_search($normalizer, $this->normalizers, true)]);
|
|
|
|
|
|
+ return isset($this->encoders[$format]) && $this->encoders[$format] instanceof DecoderInterface;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function setEncoder($format, EncoderInterface $encoder)
|
|
|
|
|
|
+ public function getEncoder($format)
|
|
{
|
|
{
|
|
- $this->encoders[$format] = $encoder;
|
|
|
|
- if ($encoder instanceof SerializerAwareInterface) {
|
|
|
|
- $encoder->setSerializer($this);
|
|
|
|
|
|
+ if (!isset($this->encoders[$format])) {
|
|
|
|
+ throw new RuntimeException(sprintf('No encoder found for format "%s".', $format));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return $this->encoders[$format];
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function getEncoder($format)
|
|
|
|
|
|
+ public function setEncoder($format, EncoderInterface $encoder)
|
|
{
|
|
{
|
|
- if (!isset($this->encoders[$format])) {
|
|
|
|
- throw new RuntimeException(sprintf('No encoder found for format "%s".', $format));
|
|
|
|
|
|
+ $this->encoders[$format] = $encoder;
|
|
|
|
+ if ($encoder instanceof SerializerAwareInterface) {
|
|
|
|
+ $encoder->setSerializer($this);
|
|
}
|
|
}
|
|
-
|
|
|
|
- return $this->encoders[$format];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function supportsSerialization($format)
|
|
|
|
|
|
+ public function removeEncoder($format)
|
|
{
|
|
{
|
|
- return isset($this->encoders[$format]);
|
|
|
|
|
|
+ if (isset($this->encoders[$format])) {
|
|
|
|
+ unset($this->encoders[$format]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function supportsDeserialization($format)
|
|
|
|
|
|
+ public function addNormalizer(NormalizerInterface $normalizer)
|
|
{
|
|
{
|
|
- return isset($this->encoders[$format]) && $this->encoders[$format] instanceof DecoderInterface;
|
|
|
|
|
|
+ $this->normalizers[] = $normalizer;
|
|
|
|
+ if ($normalizer instanceof SerializerAwareInterface) {
|
|
|
|
+ $normalizer->setSerializer($this);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function removeEncoder($format)
|
|
|
|
|
|
+ public function removeNormalizer(NormalizerInterface $normalizer)
|
|
{
|
|
{
|
|
- if (isset($this->encoders[$format])) {
|
|
|
|
- unset($this->encoders[$format]);
|
|
|
|
- }
|
|
|
|
|
|
+ unset($this->normalizers[array_search($normalizer, $this->normalizers, true)]);
|
|
}
|
|
}
|
|
}
|
|
}
|