Open grosfaignan opened 4 years ago
solved by :
adding
Doctrine\Persistence\ObjectManager: '@doctrine.orm.default_entity_manager'
into :
C:\wamp64\www\tutoSymfony\demo\config\services.yaml
need to find why ObjectManager need '@doctrine.orm.default_entity_manager' as alias
You can type-hint with EntityManagerInterface instead of ObjectManager. I found this out when defining a Symfony as a service
if you solveding:
use Doctrine\Persistence\ManagerRegistry; ... public function create(Request $request, ManagerRegistry $manager) { if ($request->request->count() > 0) { $article = new Article(); $article->setTitle($request->request->get('title')) ... $manager->getManager()->persist($article); $manager->getManager()->flush(); } return $this->render('blog/create.html.twig'); }
if you solveding:
use Doctrine\Persistence**ManagerRegistry; ... public function create(Request $request, ManagerRegistry $manager) { if ($request->request->count() > 0) { $article = new Article(); $article->setTitle($request->request->get('title')) ... $manager->getManager()->persist($article); $manager->getManager()**->flush(); } return $this->render('blog/create.html.twig'); }
domoquick
Your answer was of great importance to me as a newbie in symfony. So she solved my problem perfectly. Thanks to you
problem appear when trying to instance ObjectManager class, ti seems to be aliassed by
Problem appear after adding
in
problem appear cause object manager seems to need an alias to be found