Created
August 2, 2013 13:07
-
-
Save Chrysweel/6139735 to your computer and use it in GitHub Desktop.
Serialize twice
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
My controller: | |
/** | |
* @ParamConverter("channel", class="ApiBundle:Channel") | |
*/ | |
public function showAction(Channel $channel, Request $request) | |
{ | |
$serializer = $this->container->get('serializer'); | |
$channel = $serializer->serialize($channel, 'json', SerializationContext::create()->setGroups(array('list'))); | |
$view = $this->view($channel, 200); | |
return $this->handleView($view); | |
} | |
My Entity: | |
class Channel | |
{ | |
/** | |
* @var integer $id | |
* @Groups({"list", "details"}) | |
* | |
* @ORM\Column(name="id", type="integer") | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
private $id; | |
/** | |
* @Groups({"list"}) | |
* @var string $nombre | |
* @ORM\Column(name="nombre", type="string", length=255) | |
*/ | |
private $nombre; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment