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