made (de)normalizeObject() private
This commit is contained in:
parent
054e41573e
commit
1eecf1a5d1
@ -254,7 +254,7 @@ class XmlEncoder extends SerializerAwareEncoder implements DecoderInterface, Nor
|
||||
return $append;
|
||||
}
|
||||
if (is_object($data)) {
|
||||
$data = $this->serializer->normalizeObject($data, $this->format);
|
||||
$data = $this->serializer->normalize($data, $this->format);
|
||||
if (null !== $data && !is_scalar($data)) {
|
||||
return $this->buildXml($parentNode, $data);
|
||||
}
|
||||
@ -312,7 +312,7 @@ class XmlEncoder extends SerializerAwareEncoder implements DecoderInterface, Nor
|
||||
} elseif ($val instanceof \Traversable) {
|
||||
$this->buildXml($node, $val);
|
||||
} elseif (is_object($val)) {
|
||||
return $this->buildXml($node, $this->serializer->normalizeObject($val, $this->format));
|
||||
return $this->buildXml($node, $this->serializer->normalize($val, $this->format));
|
||||
} elseif (is_numeric($val)) {
|
||||
return $this->appendText($node, (string) $val);
|
||||
} elseif (is_string($val)) {
|
||||
|
@ -119,9 +119,13 @@ class Serializer implements SerializerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Normalizes an object into a set of arrays/scalars
|
||||
*
|
||||
* @param object $object object to normalize
|
||||
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
||||
* @return array|scalar
|
||||
*/
|
||||
public function normalizeObject($object, $format = null)
|
||||
private function normalizeObject($object, $format = null)
|
||||
{
|
||||
if (!$this->normalizers) {
|
||||
throw new \LogicException('You must register at least one normalizer to be able to normalize objects.');
|
||||
@ -141,9 +145,14 @@ class Serializer implements SerializerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Denormalizes data back into an object of the given class
|
||||
*
|
||||
* @param mixed $data data to restore
|
||||
* @param string $class the expected class to instantiate
|
||||
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
||||
* @return object
|
||||
*/
|
||||
public function denormalizeObject($data, $class, $format = null)
|
||||
private function denormalizeObject($data, $class, $format = null)
|
||||
{
|
||||
if (!$this->normalizers) {
|
||||
throw new \LogicException('You must register at least one normalizer to be able to denormalize objects.');
|
||||
|
@ -83,46 +83,6 @@ interface SerializerInterface
|
||||
*/
|
||||
function decode($data, $format);
|
||||
|
||||
/**
|
||||
* Normalizes an object into a set of arrays/scalars
|
||||
*
|
||||
* @param object $object object to normalize
|
||||
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
||||
* @return array|scalar
|
||||
*/
|
||||
function normalizeObject($object, $format = null);
|
||||
|
||||
/**
|
||||
* Denormalizes data back into an object of the given class
|
||||
*
|
||||
* @param mixed $data data to restore
|
||||
* @param string $class the expected class to instantiate
|
||||
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
||||
* @return object
|
||||
*/
|
||||
function denormalizeObject($data, $class, $format = null);
|
||||
|
||||
/**
|
||||
* @param NormalizerInterface $normalizer
|
||||
*/
|
||||
function addNormalizer(NormalizerInterface $normalizer);
|
||||
|
||||
/**
|
||||
* @param NormalizerInterface $normalizer
|
||||
*/
|
||||
function removeNormalizer(NormalizerInterface $normalizer);
|
||||
|
||||
/**
|
||||
* @param string $format format name
|
||||
* @param EncoderInterface $encoder
|
||||
*/
|
||||
function setEncoder($format, EncoderInterface $encoder);
|
||||
|
||||
/**
|
||||
* @return EncoderInterface
|
||||
*/
|
||||
function getEncoder($format);
|
||||
|
||||
/**
|
||||
* Checks whether the serializer can serialize the given format
|
||||
*
|
||||
@ -139,8 +99,29 @@ interface SerializerInterface
|
||||
*/
|
||||
function supportsDeserialization($format);
|
||||
|
||||
/**
|
||||
* @return EncoderInterface
|
||||
*/
|
||||
function getEncoder($format);
|
||||
|
||||
/**
|
||||
* @param string $format format name
|
||||
* @param EncoderInterface $encoder
|
||||
*/
|
||||
function setEncoder($format, EncoderInterface $encoder);
|
||||
|
||||
/**
|
||||
* @param string $format format name
|
||||
*/
|
||||
function removeEncoder($format);
|
||||
|
||||
/**
|
||||
* @param NormalizerInterface $normalizer
|
||||
*/
|
||||
function addNormalizer(NormalizerInterface $normalizer);
|
||||
|
||||
/**
|
||||
* @param NormalizerInterface $normalizer
|
||||
*/
|
||||
function removeNormalizer(NormalizerInterface $normalizer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user