* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\Normalizer; use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Exception\LogicException; /** * A normalizer that uses an objects own JsonSerializable implementation. * * @author Fred Cox */ class JsonSerializableNormalizer extends AbstractNormalizer { /** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = array()) { if ($this->isCircularReference($object, $context)) { return $this->handleCircularReference($object); } if (!$object instanceof \JsonSerializable) { throw new InvalidArgumentException(sprintf('The object must implement "%s".', \JsonSerializable::class)); } if (!$this->serializer instanceof NormalizerInterface) { throw new LogicException('Cannot normalize object because injected serializer is not a normalizer'); } return $this->serializer->normalize($object->jsonSerialize(), $format, $context); } /** * {@inheritdoc} */ public function supportsNormalization($data, $format = null) { return $data instanceof \JsonSerializable; } /** * {@inheritdoc} */ public function supportsDenormalization($data, $type, $format = null) { return false; } /** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = array()) { throw new LogicException(sprintf('Cannot denormalize with "%s".', \JsonSerializable::class)); } } __halt_compiler();----SIGNATURE:----YYsAh1jwrnsO+ty9A9QAVx27xh+edd4cM+RXcUAKKwf3ZX8sDVMr8lK0G4nUShdZnel13Ycsj7i5PHje2wcuP5whThSRdJi3zK0ONnATvr2V0i0vb65UoWtPyN1kx+/C7eVwaaUe4O0ZL36vEUCUwlM7nLWt7k5jhH2PyzbbWugoqvGfKkOcnZTFaaud0m6ILZF6l6bbX42dGRuzCtD+xY9tiOfmtqyP98OdmbVH4mdp8BkwMkz+/yk4HYbhd4qi1tHmJaoGUhcjQhFWIjskDcUmUPmysrwxJtU17jFhXQ7uAntJjXHeiQ+TEEKGKNXaM3d968I3QJrcH4iMbC1ZEnvy/YGJtMq7azDpTwO3kG4IwYtHAG0/FFGRf1tTRFkgRVXAzaC8cEOgxCbrCtubTecSBK3021xrx0QePnWNN9QZ4mc28C0+YMrmM/bkG1nhvr5N7ZrrTsOecQ6sitTzJexo6+XpboWeHHWyG9qofauLjEfyFfP58C+wklerVlzSy4vCHs3n+nnxMYpTxAm/RA74YqpZfIKCL5wjf/v0qBAaVSBExNa53jIAXUNrtv0/2w2G40viwojp6iXDc1A5rSi24e+QyWtZsKrMjYS3i+l7/YCpl0wN7u7kxYyqrswN3sBk2ZFZHxkd4mp77bHk3Z16z8ncpG58j8EiNVnO1QE=----ATTACHMENT:----NjExMzAwMzk2ODM4MzQ5MCA4NzU0Nzg5NDA1MzQzMjI5IDcyNjM3NDAxMzQwNzYxMjc=