* * 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:----j3pKcWXSRAGTkg2s4ETaUPt7AvjfkBuU9zOy11huNufLJS8oyuLq4C0FD8/LxJLCxiO9ZLHvS/U9UcVCy5FdtOYxJ4UYLdWN3yazm0PT0eqZGgpOTpqGLUnernZtcRtwFHvn+FITkhsHtBv+mSrbT72uUnLGV/wJ5TdNuFGLrZpIdHLA77iR6ugttFpUPUUK/NK5v/b1VspETlWnzRv6Db6CzwzzO+VNUDshKqfDQF0FD7/dzDbTOVNu3Fe6baKV7n7pZ+nPUWCYT9f0ZBtJ6I6tz6Y1FgV2yZQ4jfFuYOzk+dvVg7KqpD7kdRqNnSBMMowCjsJiY/evF+3+AgUeCowZLDllGkCZ+4lZQ5+q/RVs5BK9knvt/5toNWOubXqC3GXSrfIwXOJXXx+mDT2T1/HPkKnOj9a9XNG3duqH3uo+DF5gLt5D8QUjy+nyLt01C9yNxT59RnokAnlXaW4G6H4xm9yQ7Wo9jXPoRThnme2ZM9K0zizXtKFSMvf31kdfCWmOb2wvJWO9u1RHyNrogokKIUhV2kyPiztmH4gs0ikpUBfEUPfdbp7K19flNMO19BJSFah4RxK+xetCAwIS+cbpe9NoF5c8JE75/E9iJHxEsVORQnRZNugEj8PK9JfPa4WtL1nuNnBahtH0Qj/CttDBLr6LrEwVRX8QJByevP4=----ATTACHMENT:----MjYyNDU1NDA4NTY2NDkxIDU3ODc2OTQxODA3NjQ2NDYgMTQyMjIyMDQ0NDE1MDgzMQ==