How do I json the relationships of an entity in doctrine? I've looked around and made a few attempts but nothing that worked until now.
I'm doing this and returns the normal json (without the relationships):
$list = $this->getEm()->createquery('select u from Ticket\Entity\Ticket u');
$query = $list->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
return new \Zend\View\Model\JsonModel($query);
Ticket class relationship with user:
/**
* @ORM\ManyToOne(targetEntity="Ticket\Entity\Usuario", inversedBy="ticket")
* @ORM\JoinColumn(name="usuario_id", referencedColumnName="id")
*
*/
protected $usuario;
output:
[{"id":41,"description":"teste"},{"id":38,"description":"teste1"}]
Is there any "trick" to do this? vlw