title: Symfony 2: Deserialize object in twig
body: <p>I'm a newbie and this is my first question so please be nice with me :)</p>
  
  <p>In my Symfony 2 project I want to pass an $user object from my controller to the twig template. This object contains all relevant Information (like username, activepage ...) for rendering the view. My problem is that I would also like to put the result of mysqli database query inside the object. To be able to retrieve it in my twig template, I need two serialize the result object(array?) in the controller before passing. Unfortunately I dont know a way how to deserialize that object in twig( no twig filter available).</p>
  
  <p>My questions:</p>
  
  <ol>
  <li>Is this actually an elegant way or should i rather pass all objects in an array to the template?</li>
  <li>Would it work to write a deserialize function inside the user class, which i can call in the twig template?</li>
  <li>Will performance be ok?</li>
  <li>How do the experienced people do this?  </li>
  </ol>
  
  <p>Thx for helping!</p>