Symfony get connected user id from entity

后端 未结 3 1386
无人共我
无人共我 2021-01-25 12:53

In a Symfony2.8/Doctrine2 application, I need to store in each row of my SQL tables the id of the user who created or updated the row (users can connect with Ldap).

So al

3条回答
  •  借酒劲吻你
    2021-01-25 13:32

    @ORM\PrePersist and other callback methods used in the entity are suppose to contain simple logic and be independant of other services.

    You need to create event listener or subscriber to listen postPersist doctrine event and fill in corresponding attribute. Check How to Register Event Listeners and Subscribers

提交回复
热议问题