How to call Entity Manager in a constructor?
I've been trying to call Entity Manager in a constructor: function __construct() { $this->getDoctrine()->getEntityManager(); ... but, as I've seen in this answer: Stackoverflow question , it can't be done. So I wonder if there is a way to achieve it, as I have to call it often, and want to do some stuff in the constructor after getting the repository. Edit: I've tried with @MKhalidJunaid answer: //src/MSD/HomeBundle/Resources/config/services.yml services: imageTransController.custom.service: class: MSD\HomeBundle\Controller\ImageTransController arguments: EntityManager: "@doctrine.orm.entity