title: Symfony2, How to cast data type in a twig file?
body: <p>I have some scenario like below :</p>
  
  <pre><code>/**
   * @ORM\Entity
   * @ORM\Table(name="role")
   */
  class Role
  {
      /**
       * @ORM\OneToMany(targetEntity="RolesFeatures", mappedBy="role", cascade={"all"})
       **/
      private $rolesFeatures;
  }
  </code></pre>
  
  <p>In my index file I would like to get them:</p>
  
  <pre><code>{{ role.rolesFeatures.getId() }}
  </code></pre>
  
  <p>I get this :</p>
  
  <pre><code> An exception has been thrown during the rendering of a template ("Catchable Fatal
   Error: Object of class Doctrine\ORM\PersistentCollection could not be converted to string
   in C:\wamp\www\PMI_sf2\app\cache\dev\twig\63\81\679fca1c2da64d0ebbcd5661bc6d.php line 99")
   in PMIHomePagesBundle:HomePages:mainHome.html.twig at line 49.
  </code></pre>
  
  <p>How I can Cast Doctrine\ORM\PersistentCollection to it real object class ?</p>