There are several articles that relate to this topic, but none of them represented a practical solution for me. My goal is to put some basic methods (the ones that I need in each controller anyway) in the base controller, for example.
$this->getEntityManager(); $this->getRequest(); $this->getRepository($entityName);
How can I do that?
AFAIK, we need to implement services in the base controller, but how can I say that classes use the service for their superclass? There is some decent article on controllers and dependency injection [1], but finally I am stuck with this approach too, see my comment here: [2]
[1] http://miller.limethinking.co.uk/2011/04/15/symfony2-controller-as-service/
[2] http://miller.limethinking.co.uk/2011/04/15/symfony2-controller-as-service/#comment-579
pseudo code
MyBaseController impliments Symfony\Component\Di\ContainerAwareInterface setContainer($container) $this->container = $container getEntityManager return $this->container->get('doctrine.orm.entity_manager')
Source: https://habr.com/ru/post/886775/More articles:Querying a dictionary using RavenDb - ravendbWPF: Search for 3D visual images partially inside a 2D rectangle - c #64-bit functions in a 32-bit application? - c ++Scroll bars and alignment by client in a nested form - delphiInterception of outgoing calls when hanging - androidStoring a binary string in MySQL - bit-manipulationhow to remove all li in my ul using id? - javascriptAndroid Notification Icon - androidHTML Link Agility Pack Null Link - c #how to write a method with delegation option in C # /. NET 4.0? - c #All Articles