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::
235
235
236
236
class UserController extends Controller
237
237
{
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)
246
239
{
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
250
242
$em = $this->getDoctrine()->getManager();
251
243
$em = $this->getDoctrine()->getManager('default');
252
244
$em = $this->get('doctrine.orm.default_entity_manager');
You can’t perform that action at this time.
0 commit comments