Forked from damienalexandre/New way to set the encoder.
Created
December 31, 2011 19:04
-
-
Save piotrplenik/1545031 to your computer and use it in GitHub Desktop.
Playing with the Symfony2 serializer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Inside your action | |
$this->serializer = new \Symfony\Component\Serializer\Serializer(); | |
$this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer()); | |
$this->serializer->setEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder()); | |
return $this->createResponse($this->serializer->encode($page, 'xml'), 200, array('Content-Type' => 'application/xml')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment