Doctrine\ORM\EntityManager::flush PHP Method

flush() public method

This effectively synchronizes the in-memory state of managed objects with the database.
public flush ( )
    public function flush()
    {
        $this->errorIfClosed();
        $this->unitOfWork->commit();
    }

Usage Example

コード例 #1
1
 /**
  * @param PostFlushEventArgs $args
  */
 public function postFlush(PostFlushEventArgs $args)
 {
     if ($this->isInProgress) {
         return;
     }
     $this->initializeFromEventArgs($args);
     if (count($this->queued) > 0) {
         $toOutDate = [];
         foreach ($this->queued as $customerIdentity => $groupedByEntityUpdates) {
             foreach ($groupedByEntityUpdates as $data) {
                 /** @var Account $account */
                 $account = is_object($data['account']) ? $data['account'] : $this->em->getReference('OroCRMAccountBundle:Account', $data['account']);
                 /** @var Channel $channel */
                 $channel = is_object($data['channel']) ? $data['channel'] : $this->em->getReference('OroCRMChannelBundle:Channel', $data['channel']);
                 $entity = $this->createHistoryEntry($customerIdentity, $account, $channel);
                 $toOutDate[] = [$account, $channel, $entity];
                 $this->em->persist($entity);
             }
         }
         $this->isInProgress = true;
         $this->em->flush();
         foreach (array_chunk($toOutDate, self::MAX_UPDATE_CHUNK_SIZE) as $chunks) {
             $this->lifetimeRepo->massStatusUpdate($chunks);
         }
         $this->queued = [];
         $this->isInProgress = false;
     }
 }
All Usage Examples Of Doctrine\ORM\EntityManager::flush