title: Symfony2.3 Better way to get EntityManager inside a Controller
body: <p>I'm using <code>Symfony2.3</code> and I currently using EntityManager as shown inside <strong>__construct()</strong></p>
  
  <p>Which its a better aproach using EntityManager from <strong>__construct()</strong> or using inside each method ? as shown in <strong>public indexAction()</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * QuazBar controller.
   *
   */
  class QuazBarController extends Controller
  {
  
      public function __construct()
      {
          $this-&gt;em = $GLOBALS['kernel']-&gt;getContainer()-&gt;get('doctrine')-&gt;getManager();
      }
  
      /**
       * Lists all QuazBar entities.
       *
       */
      public function indexAction(Request $request)
      {
          $session    = $request-&gt;getSession();
          $pagina     = $request-&gt;query-&gt;get('page', 1);
          $em         = $this-&gt;getDoctrine()-&gt;getManager();
      }
  </code></pre>