title: Symfony key array in twig
body: <p>I want to show information from one entity.</p>
  
  <p>The entity that has the information is related to another , so I use a query to obtain that information.</p>
  
  <pre><code>class Playlist
  {
      private $id;
  
      private $name;
  
      private $items;
  
      public function __construct()
      {
          $this-&gt;items = new \Doctrine\Common\Collections\ArrayCollection();
      }
  
      public function addItem(\Publicartel\AppBundle\Entity\PlaylistContent $content)
      {
          $content-&gt;setPlaylist($this);
  
          $this-&gt;items-&gt;add($content);
  
          return $this;
      }
  
      public function removeItem(\Publicartel\AppBundle\Entity\PlaylistContent $content)
      {
          $this-&gt;items-&gt;removeElement($content);
      }
  
      public function getItems()
      {
          return $this-&gt;items;
      }
  }
  
  class PlaylistContent
  {
      private $content;
  
  public function setContent(\Publicartel\AppBundle\Entity\Content $content = null)
      {
          $this-&gt;content = $content;
  
          return $this;
      }
  
      public function getContent()
      {
          return $this-&gt;content;
      }
  
  }
  </code></pre>
  
  <p>// The controller: </p>
  
  <pre><code>$playlists = $em-&gt;getRepository('PublicartelAppBundle:Playlist')-&gt;getAllPlaylist();
  
  return $this-&gt;render('PublicartelAppBundle:Player:calendar.html.twig', array( 
  'playlists' =&gt; $playlists,
  ));
  </code></pre>
  
  <p>// The query </p>
  
  <pre><code>public function getAllPlaylist()
      {
          $em = $this-&gt;getEntityManager();
  
          $dql = 'SELECT p, cnt, plc FROM Publicartel\AppBundle\Entity\Playlist p
                  LEFT JOIN p.items cnt
                  LEFT JOIN cnt.content plc';
  
          $query = $this-&gt;getEntityManager()
              -&gt;createQuery($dql)
              -&gt;setHydrationMode(\Doctrine\ORM\Query::HYDRATE_ARRAY);
  
          return $query-&gt;execute();
      }
  </code></pre>
  
  <p>The consultation seeks elements of the content entity, so it takes a left join on ' items' and 'content'.</p>
  
  <p>// The twig template</p>
  
  <p>I have sought access to the element of two ways:</p>
  
  <pre><code>{% for playlist in playlists.items.content %}
      &lt;img src="/{{ playlist.path}}"&gt; 
  {% endfor %}
  </code></pre>
  
  <p>Key "items" for array with keys " 0, 1 " does not exist in PublicartelAppBundle : Player : calendar.html.twig at line 215</p>
  
  <pre><code>{% for playlist in playlists %}
      &lt;img src="/{{ playlist.items.content.path }}"&gt;
  {% endfor %}
  </code></pre>
  
  <p>Key "content" for array with keys "0, 1" does not exist in PublicartelAppBundle:Player:calendar.html.twig at line 223</p>
  
  <p>'Path' is an attribute for entity 'Content' that I want show. </p>