@param LifecycleEventArgs $eventArgs

@return string
170550
protected function getUpdateByNameFromUser(LifecycleEventArgs $eventArgs)
    {
        if (!$this->hasCurrentUser()) {
            return $this->getFallbackUser();
        }

        if (null !== $name = $this->getNameFromUser($this->currentUser())) {
            return $name;
        }

        $identifier = 'id';
        $user       = $this->currentUser();
        $repo       = $eventArgs->getEntityManager()->getRepository($this->getUserClass());

        // did not implement standard methods, try and look them up using identifier
        if ($user instanceof AuthenticatableContract) {
            $identifier = $user->getAuthIdentifierName();
        }

        if (null !== $user = $repo->findOneBy([$identifier => $user->getAuthIdentifier()])) {
            if (null !== $name = $this->getNameFromUser($user)) {
                return $name;
            }
        }

        // fall back completely
        return $this->getFallbackUser();
    }
984975
public function prePersist(LifecycleEventArgs $eventArgs)
	{
		$entity = $eventArgs->getEntity();

		if ($entity instanceof TimestampableInterface) {
			$now = new \DateTime();
			$entity->setModificationTime($now);
			$entity->setCreationTime($now);
		}
	}
719399
public function prePersist(EventArgs $eventArgs)
    {
        if (method_exists($eventArgs, 'getEntity')) {
            $this->_triggerEvent(Events::prePersist, $eventArgs->getEntity(), $eventArgs);
        }
    }
994625
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $dm  = $eventArgs->getDocumentManager();
        $uow = $dm->getUnitOfWork();
        
        $filter = function ($element) {
            return $element instanceof ApplicationInterface
                   && $element->getPermissions()->hasChanged();
        };
        
        $inserts = array_filter($uow->getScheduledDocumentInsertions(), $filter);
        $updates = array_filter($uow->getScheduledDocumentUpdates(), $filter);
        
        foreach (array($inserts, $updates) as $isUpdate => $documents) {
            foreach ($documents as $document) { /* @var \Applications\Entity\Application $document */
                $permissions = $document->getPermissions();
               
                foreach ($document->getAttachments() as $attachment) {  /* @var \Applications\Entity\Attachment $attachment */
                    $attachment->getPermissions()
                               ->clear()
                               ->inherit($permissions);
                    if ($isUpdate) {
                        $uow->computeChangeSet(
                            $dm->getClassMetadata(get_class($attachment)),
                            $attachment
                        );
                    }
                }
                
                if ($image = $document->getContact()->getImage()) {
                    $image->getPermissions()
                          ->clear()
                          ->inherit($permissions);
                    if ($isUpdate) {
                        $uow->computeChangeSet(
                            $dm->getClassMetadata(get_class($image)),
                            $image
                        );
                    }
                }
            }
        }
    }
1262250
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();
        $reflection = $classMetadata->reflClass;

        if (!$reflection || $reflection->isAbstract()) {
            return;
        }

        if ($reflection->implementsInterface(TranslatableInterface::class)) {
            $this->mapTranslatable($classMetadata);
        }

        if ($reflection->implementsInterface(TranslationInterface::class)) {
            $this->mapTranslation($classMetadata);
        }
    }
139036
public function postLoad(LifecycleEventArgs $eventArgs)
    {
        $this->loadTranslation(
            $eventArgs->getEntityManager(),
            $eventArgs->getEntity(),
            $this->getLocale()
        );
    }
855885
public function postFlush(PostFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();
        foreach ($uow->getIdentityMap() as $entities) {
            foreach ($entities as $entity){
                $this->collectEventsFromEntity($entity);
            }
        }
    }
1325742
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        /** @var ClassMetadata $metadata */
        $metadata = $eventArgs->getClassMetadata();

        $reflectionClass = $metadata->getReflectionClass();

        if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Labelable')) {
            return;
        } // return if current entity doesn't use Labelable trait

        $this->logger->debug('[LabelableListener] Entering LabelableListener for « loadClassMetadata » event');

        // setting default mapping configuration for Labelable

        // name
        $metadata->mapField([
            'fieldName' => 'label',
            'type'      => 'string',
            'nullable'  => true,
        ]);

        $this->logger->debug(
            '[LabelableListener] Added Labelable mapping metadata to Entity',
            ['class' => $metadata->getName()]
        );
    }
489036
public function prePersist(LifecycleEventArgs $args)
    {
        $entity        = $args->getEntity();
        $entityManager = $args->getEntityManager();

        $classMetadata = $entityManager->getClassMetadata(get_class($entity));

        if (false == $this->isModular($classMetadata)) {
            return;
        }

        if (null === $entity->getModule() && null !== $this->getModuleManager()->getCurrentModule()) {
            $entity->setModule($this->getModuleManager()->getCurrentModule());
        }
    }
118881
public function preUpdate(LifecycleEventArgs $eventArgs)
    {
        $document = $eventArgs->getDocument();
        if (!$document instanceof JobInterface) {
            return;
        }
        $dm = $eventArgs->getDocumentManager();
        $changeset = $dm->getUnitOfWork()->getDocumentChangeset($document);
        
        if (!isset($changeset['user'])) {
            return;
        }
        
        $userId = $document->getUser()->getId();

        $dm->createQueryBuilder('Applications\Entity\Application')
            ->update()->multiple(true)
            ->field('refs.jobs.userId')->set($userId)
            ->field('refs.jobs.__id__')->equals($document->getId())
            ->field('refs.jobs.userId')->notEqual($userId)
            ->getQuery()
            ->execute();
    }
480802
public function postLoad(LifecycleEventArgs $args)
    {
        $document = $args->getDocument();

        // Sometimes $document is a doctrine proxy class, we therefore need to retrieve it's real class
        $name = $args->getDocumentManager()->getClassMetadata(get_class($document))->getName();

        if (!isset($this->mappings[$name])) {
            return;
        }

        $metadata = $this->mappings[$name];

        if (isset($metadata['fallback_locale'])) {
            $setter = 'set' . ucfirst($metadata['fallback_locale']);
            $document->$setter($this->fallbackLocale);
        }
        if (isset($metadata['current_locale'])) {
            $setter = 'set' . ucfirst($metadata['current_locale']);
            $document->$setter($this->currentLocale);
        }
    }
656883
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();
        $entityName = (string) $classMetadata->getName();

        // We dynamically set the user class that was configured in the configuration
        if ($entityName == 'Kunstmaan\NodeBundle\Entity\QueuedNodeTranslationAction') {
            $mapping = array(
                'fieldName' => 'user',
                'targetEntity' => $this->className,
                'joinColumns' => array(array(
                    'name' => 'user_id',
                    'referencedColumnName' => 'id',
                    'unique' => false,
                    'nullable' => true,
                )),
            );
            $classMetadata->mapManyToOne($mapping);
        }
    }
600226
public function prePersist(LifecycleEventArgs $eventArgs)
    {
        $entity = $eventArgs->getObject();

        if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) {
            return;
        }

        $this->logger->debug(
            '[TimestampableListener] Entering TimestampableListener for « prePersist » event'
        );

        $now = new DateTime('NOW');
        $entity->setCreatedAt($now);
        $entity->setUpdatedAt($now);
    }
327575
public function postRemoveEntity(LifecycleEventArgs $eventArgs)
    {
        $file = $eventArgs->getDocument();
        if (!$file instanceof Attachment) {
            return;
        }
        
        $dm     = $eventArgs->getDocumentManager();
        //$repo   = $dm->getRepository('Applications\Entity\Application');

        $fileId = new \MongoId($file->id);
        
        $dm->createQueryBuilder('Applications\Entity\Application')
           ->update()->multiple(true)
           ->field('attachments')->equals($fileId)->pull($fileId)
           ->getQuery()->execute();
        
        
        $dm->createQueryBuilder('Applications\Entity\Application')
           ->update()->multiple(true)
           ->field('contact.image')->equals($fileId)->set(null)
           ->getQuery()->execute();
    }
179620
public function postLoad(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();

        if (!$entity instanceof TranslatableInterface) {
            return;
        }

        $entity->initializeTranslations();
        $entity->setCurrentLocale($this->localeProvider->getCurrentLocale());
        $entity->setFallbackLocale($this->localeProvider->getFallbackLocale());
    }
1231522
public function onFlush(OnFlushEventArgs $eventArgs)
	{
		$em = $eventArgs->getEntityManager();
		$uow = $em->getUnitOfWork();

		foreach ($uow->getScheduledEntityUpdates() as $entity) {
			if ($entity instanceof TimestampableInterface) {
				$entity->setModificationTime();
				$className = get_class($entity);
				$class = $em->getClassMetadata($className);
				$uow->recomputeSingleEntityChangeSet($class, $entity);
			}
		}
	}
817252
public function postRemoveEntity(LifecycleEventArgs $eventArgs)
    {
        $file = $eventArgs->getDocument();
        if (!$file instanceof Attachment) {
            return;
        }
        
        $fileId = new \MongoId($file->getId());
        $dm = $eventArgs->getDocumentManager();
        $dm->createQueryBuilder('Cv\Entity\Cv')
           ->update()->multiple(true)
           ->field('attachments')->equals($fileId)->pull($fileId)
           ->getQuery()->execute();
    }