4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Serializer\Normalizer;
15 * @author Jordi Boggiano <j.boggiano@seld.be>
17 class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerInterface, DenormalizerInterface
22 public function normalize($object, $format = null, array $context = array())
24 return $object->normalize($this->serializer, $format, $context);
30 public function denormalize($data, $class, $format = null, array $context = array())
32 $object = new $class();
33 $object->denormalize($this->serializer, $data, $format, $context);
39 * Checks if the given class implements the NormalizableInterface.
41 * @param mixed $data Data to normalize
42 * @param string $format The format being (de-)serialized from or into
46 public function supportsNormalization($data, $format = null)
48 return $data instanceof NormalizableInterface;
52 * Checks if the given class implements the NormalizableInterface.
54 * @param mixed $data Data to denormalize from
55 * @param string $type The class to which the data should be denormalized
56 * @param string $format The format being deserialized from
60 public function supportsDenormalization($data, $type, $format = null)
62 if (!class_exists($type)) {
66 return is_subclass_of($type, 'Symfony\Component\Serializer\Normalizer\DenormalizableInterface');