I have some entities with abstract class : EntityDated wich mean that the entity contain 4 commons fields : created, updated, created_by and updated_by. I want update the 4 data when I create entity and update 'updated' and 'updated_by' when I update the entity.
I made a service calling my listener :
public function preFlush(PreFlushEventArgs $eventArgs)
{
$token = $this->container->get('security.context')->getToken();
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
// Inserts
foreach ($uow->getScheduledEntityInsertions() as $entity) { …Run Code Online (Sandbox Code Playgroud) doctrine-orm ×1