How I can get the current user into my entity classes?
问题 I am developing my first Symfony 4 application and I migrating from Symfony 2+ and symfony 3+. Right now I am developing a back-end and all of my entity classes have a addedBy() and updatedBy() methods where I need to record the current logged in administrator. I would like to have something like an event listener where I do not have to set those methods in all of my controllers. How to accomplish this? 回答1: First, to simplify matters and help down the road I would create an interface this