title: Getting an object from an array by the objects name in twig
body: <p>I want to store my template text in a databse table.</p>
  
  <pre><code>Name     |    Text                         |  .....
  ----------------------------------------------------
  Title    | My very own Blog                | ......
  Intro    | Hello stranger, this is my blog |
  </code></pre>
  
  <p>Each item is a record and I want to access each item directly in Twig.</p>
  
  <p>Currently my code is:</p>
  
  <pre><code>public function indexAction()
  {
    $ObjArr=$EntityManager-&gt;getRepository('myBundle:tplitems')-&gt;findAll();
  
    foreach($ObjArr as $obj) {
      $tplitems[$obj-getName()]=$obj;
    }
  
    return $this-&gt;render('myBundle::index.html.twig',array('tplitems'=&gt;$tplitems,))
  }
  </code></pre>
  
  <p>which lets me write in Twig:</p>
  
  <pre><code>{{ tplitems.title.text }}
  </code></pre>
  
  <p>Is there a better/cleaner way to do this ?</p>