小编Kme*_*nin的帖子

Doctrine2 : preFlush getScheduledEntityInsertions() works but not getScheduledEntityUpdates()

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

2
推荐指数
1
解决办法
2038
查看次数

标签 统计

doctrine-orm ×1