07.
Understanding Autowiring Logic
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
5 Comments
I get this deprecation error: "Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. Try changing the type-hint for argument "$em" of method "AppBundle\Service\Settings::__construct()" to one of its parents: interface "Doctrine\ORM\EntityManagerInterface", or interface "Doctrine\Common\Persistence\ObjectManager"."
I don't understand, why I have to typehint the EntityManagerInterface and not the EntityManager?
Because typehinting on interface has much more flexibility than on exact class. That allows you to change realisation of injected class without changing all the typehints where it's used.
Hey Trafficmanagertech
As far as I know that change was made to encourage programmers to depend upon interfaces instead of concrete classes
Have a nice day
Nevermind, it was answered in episode 10 - https://symfonycasts.com/sc...
But if there's two or more classes in the container, which implement that interface or extend that concrete class, autowiring won't work, right?
"Houston: no signs of life"
Start the conversation!