Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2.  
  3. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  4. use Symfony\Component\Serializer\Normalizer\scalar;
  5.  
  6. class ChildNormalizer implements NormalizerInterface
  7. {
  8. public function normalize($object, $format = null, array $context = array())
  9. {
  10. return [
  11. "name" => $object->getName(),
  12. "age" => $object->getAge(),
  13. ...
  14. ];
  15. }
  16.  
  17. public function supportsNormalization($data, $format = null)
  18. {
  19. return ($data instanceof Child) && is_object($data);
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement