title: Symfony centralize code
body: <p>I am new to symfony 2.8. 
  I do the same code pattern in each of my controllers to get the same data, put in different views, following this pattern: </p>
  
  <pre><code> public function someMethod(Request $request){
      //1)  instanciate entity manager 
      $em = $this-&gt;getDoctrine()-&gt;getManager();
  
      //2)   Fetch some datas ..
      $datas = $em-&gt;getRepository('MyCustomBundle:Entity')-&gt;findAll();
      $otherDatas = $em-&gt;getRepository('MyCustomBundle:AnotherEntity')-&gt;findAll();
  
     //3) Inject datas into view
     return $this-&gt;render('MyCustomBundle:Views:myview.html.twig', array('data'=&gt;$datas,'otherDatas'=&gt;$otherDatas));
     }
  </code></pre>
  
  <p>Is it possible to factorize all the getRepositories calls and arrays injection into a separated class ? </p>
  
  <p>thanks for your help,</p>