@param PostFlushEventArgs $event

@throws ORMInvalidArgumentException
@throws OptimisticLockException
@throws \Doctrine\ORM\ORMException
338480
public function postFlush(PostFlushEventArgs $event)
    {
        $em = $event->getEntityManager();
        $valueCount = \count($this->valuesToPersist);
        foreach ($this->valuesToPersist as $value) {
            $em->persist($value);
        }
        $this->valuesToPersist = [];
        if ($valueCount > 0) {
            $em->flush();
        }
    }
1324561
@SuppressWarnings("unchecked")
   @CacheEntryModified
   public void cacheEntryModified(CacheEntryModifiedEvent<Serializable, Object> event)
   {
      if (!event.isPre() && event.getKey().equals(namesKey))
      {
         Set<String> set = (Set<String>)event.getValue();
         if (set != null)
         {
            refreshIndexes(set);
         }
      }
   }
907387
public function afterAction($event)
    {
        if ($this->schedule) {
            if ($event->result === false) {
                $exitCode = CronScheduleStatus::ERROR;
            } else {
                $exitCode = CronScheduleStatus::SUCCESS;
            }
            $this->schedule->endCronSchedule($exitCode);
            $this->schedule = null;
        }
    }
405051
public function onFlush(OnFlushEventArgs $args)
    {
        try {
            $em = $args->getEntityManager();

            $class = $em->getClassMetadata(NodeTranslation::class);

            // Collect all nodetranslations that are updated
            foreach ($em->getUnitOfWork()->getScheduledEntityUpdates() as $entity) {
                if ($entity instanceof NodeTranslation) {
                    /** @var Node $publicNode */
                    $publicNode = $entity->getPublicNodeVersion()->getRef($em);

                    // Do nothing for StructureNode objects, skip.
                    if ($publicNode instanceof HasNodeInterface && $publicNode->isStructureNode()) {
                        continue;
                    }

                    $entity = $this->updateUrl($entity, $em);

                    if ($entity !== false) {
                        $em->persist($entity);
                        $em->getUnitOfWork()->recomputeSingleEntityChangeSet($class, $entity);

                        $this->updateNodeChildren($entity, $em, $class);
                    }
                }
            }
        } catch (MappingException $e) {
            // Different entity manager without this entity configured in namespace chain. Ignore
        }
    }
1005495
public function onFlush(OnFlushEventArgs $args): void
    {
        $token = $this->getTokenStorage()->getToken();

        if (!$this->getPermissionManager()->isEnabled()
                || null === $token || $token instanceof ConsoleToken) {
            return;
        }

        $uow = $args->getEntityManager()->getUnitOfWork();
        $this->getObjectFilter()->beginTransaction();

        $this->checkAllScheduledByAction($uow->getScheduledEntityInsertions(), 'create');
        $this->checkAllScheduledByAction($uow->getScheduledEntityUpdates(), 'edit');
        $this->checkAllScheduledByAction($uow->getScheduledEntityDeletions(), 'delete');

        $this->getObjectFilter()->commit();
    }
577218
public function preFlush(PreFlushEventArgs $args)
    {
        $objectManager = $args->getEntityManager();
        $unitOfWork = $objectManager->getUnitOfWork();

        $entityMap = $unitOfWork->getIdentityMap();
        foreach ($entityMap as $objectClass => $objects) {
            if (in_array(UploadObjectInterface::class, class_implements($objectClass))) {
                foreach ($objects as $object) {
                    $this->prepareUploadFileReferences($object);
                }
            }
        }
    }
675225
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $this->eventQueue->setOpened(true);

        $uow = $eventArgs->getEntityManager()->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleInsert($entity);
            }
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleUpdate($entity);
            }
        }

        // TODO move collections before update ?
        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            foreach ($col as $c) {
                foreach ($c as $entity) {
                    if ($entity instanceof ResourceInterface) {
                        $this->eventQueue->scheduleDelete($entity);
                    }
                }
            }
        }
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $c) {
                foreach ($c as $entity) {
                    if ($entity instanceof ResourceInterface) {
                        if ($entity->getId()) {
                            $this->eventQueue->scheduleUpdate($entity);
                        } else {
                            $this->eventQueue->scheduleInsert($entity);
                        }
                    }
                }
            }
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleDelete($entity);
            }
        }

        $this->eventQueue->flush();

        $this->eventQueue->setOpened(false);
    }
880493
public function handlePersist(PersistEvent $event)
    {
        if (!$this->supports($event->getDocument())) {
            return;
        }

        $this->persistEvents[] = $event;
    }
1354358
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            if ($entity instanceof FileInterface){
                $this->populateMeta($em, $uow, $entity);
                $this->scheduledForCopyFiles[spl_object_hash($entity)] = $entity;
            }
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {

            if ($entity instanceof FileInterface){

                if ($this->versionEnabled){
                    $em->lock($entity, LockMode::OPTIMISTIC, $entity->getCurrentVersion());
                }
                
                if (true === $entity->isScheduledForDeletion()){
                    $uow->scheduleForDelete($entity);
                    continue;
                }
                
                $changeSet = $uow->getEntityChangeSet($entity);

                if (isset($changeSet['name'])){
                    // remove old file
                    $clonedEntity = clone $entity;
                    $clonedEntity->setName($changeSet['name'][0]);
                    $this->scheduledForDeleteFiles[spl_object_hash($clonedEntity)] = $clonedEntity;
                    $this->scheduledForCopyFiles[spl_object_hash($entity)] = $entity;
                    $this->checksum($entity);
                } 

                if(isset($changeSet['name']) || isset($changeSet['hash'])){
                    $this->populateMeta($em, $uow, $entity);
                }                
            }
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            if ($entity instanceof FileInterface){
                $this->scheduledForDeleteFiles[spl_object_hash($entity)] = $entity;
            }
        }
    }
1040045
public function onKernelTerminate(PostResponseEvent $event)
    {
        if (!$event->getRequest()->hasSession()) {
            return;
        }

        $session = $event->getRequest()->getSession();

        $this->registry->refreshLastUsed($session->getId(), $session->getMetadataBag()->getLastUsed());
    }
391640
private function doRefresh($entity, array &$visited)
    {
        $oid = spl_object_id($entity);

        if (isset($visited[$oid])) {
            return; // Prevent infinite recursion
        }

        $visited[$oid] = $entity; // mark visited

        $class = $this->em->getClassMetadata(get_class($entity));

        if ($this->getEntityState($entity) !== self::STATE_MANAGED) {
            throw ORMInvalidArgumentException::entityNotManaged($entity);
        }

        $this->getEntityPersister($class->getClassName())->refresh(
            array_combine($class->getIdentifierFieldNames(), $this->entityIdentifiers[$oid]),
            $entity
        );

        $this->cascadeRefresh($entity, $visited);
    }
565036
public function postFlush()
    {
        if (!$this->enabled || $this->isHandling) {
            return;
        }

        $this->isHandling = true;

        $aliaser = $this->container->get($this->aliaserServiceId);

        while (list($record, $action) = array_shift($this->records)) {
            $aliaser->createAlias($record, $action);
        }

        $this->isHandling = false;
    }
367839
public function onFlush(\Doctrine\ORM\Event\OnFlushEventArgs $eventArgs) {
        $reCacheEntities = [];
        
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();
        
        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            $reCacheEntities[get_class($entity)] = true;
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $reCacheEntities[get_class($entity)] = true;
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $reCacheEntities[get_class($entity)] = true;
        }

        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            $reCacheEntities[get_class($entity)] = true;
        }

        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            $reCacheEntities[get_class($entity)] = true;
        }
        
        foreach ($reCacheEntities as $entityNamespace => $flag) {
            $this->recache($entityNamespace);
        }
    }
1291984
public function onKernelTerminate(PostResponseEvent $event)
	{
		if (!$this->incremented) {
			return;
		}
		
		$this->incremented = false;
		$this->memcache->decrement($this->key);
	}
876840
public function postFlush(PostFlushEventArgs $e)
    {
        $repo = $e->getEntityManager()->getRepository($this->entityName);
        if (true !== ($issues = $repo->verify())) {
            throw new \UnexpectedValueException(
                sprintf(
                    "The repository '%s' did not validate. Run the '%s' console command to find out what's going on",
                    $this->entityName,
                    RepairNestedTreeCommand::COMMAND_NAME
                )
            );
        }
    }
1283769
public function afterPrepare(Event $event)
    {
        /* @var \Guzzle\Service\Command\CommandInterface $command */
        $command = $event['command'];
        $request = $command->getRequest();

        $request->getQuery()->setAggregator(new StripeQueryAggregator());
    }
480851
public function handleScheduleRename(PersistEvent $event)
    {
        $document = $event->getDocument();

        if (!$event->getOption('auto_name')
            || !$document instanceof AutoNameBehavior
            || $event->getOption('auto_name_locale') !== $event->getLocale()
            || !$event->hasNode()
            || $event->getNode()->isNew()
        ) {
            return;
        }

        $node = $event->getNode();
        $name = $this->getName($document, $event->getParentNode(), $event->getOption('auto_rename'), $node);

        if ($name === $node->getName()) {
            return;
        }

        $uuid = $event->getNode()->getIdentifier();
        $this->scheduledRename[] = ['uuid' => $uuid, 'name' => $name, 'locale' => $event->getLocale()];
    }