Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save piotrplenik/1545031 to your computer and use it in GitHub Desktop.
Save piotrplenik/1545031 to your computer and use it in GitHub Desktop.

Revisions

  1. @damienalexandre damienalexandre renamed this gist Jan 30, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.php → New way to set the encoder.
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,6 @@

    $this->serializer = new \Symfony\Component\Serializer\Serializer();
    $this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer());
    $this->serializer->addEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());
    $this->serializer->setEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());

    return $this->createResponse($this->serializer->encode($page, 'xml'), 200, array('Content-Type' => 'application/xml'));
  2. @damienalexandre damienalexandre revised this gist Jan 23, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    <?php

    // Inside your action

    $this->serializer = new \Symfony\Component\Serializer\Serializer();
    $this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer());
    $this->serializer->addEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());
  3. @damienalexandre damienalexandre created this gist Jan 23, 2011.
    5 changes: 5 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    $this->serializer = new \Symfony\Component\Serializer\Serializer();
    $this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer());
    $this->serializer->addEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());

    return $this->createResponse($this->serializer->encode($page, 'xml'), 200, array('Content-Type' => 'application/xml'));