K
K
Karina2015-09-21 18:47:21
symfony
Karina, 2015-09-21 18:47:21

Why doesn't $em = $this->getDoctrine()->getManager(); code work?

Ordinary controller (extends from Controller). throws an error:
$em = $this->getDoctrine()->getManager();

Error: Call to a member function get() on a non-object

What is the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-09-21
Protko @Fesor

debug, break, see what $this is.

R
romashka_sky, 2015-09-26
@romashka_sky

Your Controller doesn't have a Container. Maybe you manually created a controller instance: new MyController() without injecting a Container into it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question