public function prePersist(LifecycleEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();
        $entity = $eventArgs->getEntity();

        $classMetadata = $em->getClassMetadata(get_class($entity));
        if ($this->isBlameable($classMetadata)) {
            if (!$entity->getCreatedBy()) {
                $user = $this->getUser();
                if ($this->isValidUser($user)) {
                    $entity->setCreatedBy($user);

                    $uow->propertyChanged($entity, 'createdBy', null, $user);
                    $uow->scheduleExtraUpdate($entity, [
                        'createdBy' => [null,  $user],
                    ]);
                }
            }
            if (!$entity->getUpdatedBy()) {
                $user = $this->getUser();
                if ($this->isValidUser($user)) {
                    $entity->setUpdatedBy($user);
                    $uow->propertyChanged($entity, 'updatedBy', null, $user);

                    $uow->scheduleExtraUpdate($entity, [
                        'updatedBy' => [null, $user],
                    ]);
                }
            }
        }
    }
public function prePersist(LifecycleEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();
        $entity = $eventArgs->getEntity();

        $classMetadata = $em->getClassMetadata(get_class($entity));
        if ($this->isBlameable($classMetadata)) {
            if (!$entity->getCreatedBy()) {
                $user = $this->getUser();
                if ($this->isValidUser($user)) {
                    $entity->setCreatedBy($user);

                    $uow->propertyChanged($entity, 'createdBy', null, $user);
                    $uow->scheduleExtraUpdate($entity, [
                        'createdBy' => [null,  $user],
                    ]);
                }
            }
            if (!$entity->getUpdatedBy()) {
                $user = $this->getUser();
                if ($this->isValidUser($user)) {
                    $entity->setUpdatedBy($user);
                    $uow->propertyChanged($entity, 'updatedBy', null, $user);

                    $uow->scheduleExtraUpdate($entity, [
                        'updatedBy' => [null, $user],
                    ]);
                }
            }
        }
    }
public function prePersist ( LifecycleEventArgs $ eventArgs ) { $ em = $ eventArgs -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; $ entity = $ eventArgs -> getEntity ( ) ; $ classMetadata = $ em -> getClassMetadata ( get_class ( $ entity ) ) ; if ( $ this -> isBlameable ( $ classMetadata ) ) { if ( ! $ entity -> getCreatedBy ( ) ) { $ user = $ this -> getUser ( ) ; if ( $ this -> isValidUser ( $ user ) ) { $ entity -> setCreatedBy ( $ user ) ; $ uow -> propertyChanged ( $ entity , 'createdBy' , null , $ user ) ; $ uow -> scheduleExtraUpdate ( $ entity , [ 'createdBy' => [ null , $ user ] , ] ) ; } } if ( ! $ entity -> getUpdatedBy ( ) ) { $ user = $ this -> getUser ( ) ; if ( $ this -> isValidUser ( $ user ) ) { $ entity -> setUpdatedBy ( $ user ) ; $ uow -> propertyChanged ( $ entity , 'updatedBy' , null , $ user ) ; $ uow -> scheduleExtraUpdate ( $ entity , [ 'updatedBy' => [ null , $ user ] , ] ) ; } } } }
Stores the current user into createdBy and updatedBy properties

@param LifecycleEventArgs $eventArgs
Stores the current user into createdBy and updatedBy properties