File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -235,18 +235,10 @@ the default entity manager (i.e. ``default``) is returned::
235235
236236 class UserController extends Controller
237237 {
238- protected $em;
239-
240- public function __construct(EntityManagerInterface $em)
241- {
242- $this->em = $em;
243- }
244-
245- public function indexAction()
238+ public function indexAction(EntityManagerInterface $em)
246239 {
247- // All 4 return the "default" entity manager, though using
248- // dependency injection is a best practice
249- $em = $this->em;
240+ // These methods also return the default entity manager, but it's preferred
241+ // to get it by inyecting EntityManagerInterface in the action method
250242 $em = $this->getDoctrine()->getManager();
251243 $em = $this->getDoctrine()->getManager('default');
252244 $em = $this->get('doctrine.orm.default_entity_manager');
You can’t perform that action at this time.
0 commit comments