当前位置: 首页>>代码示例>>PHP>>正文


PHP UnitOfWork::getScheduledEntityInsertions方法代码示例

本文整理汇总了PHP中Doctrine\ORM\UnitOfWork::getScheduledEntityInsertions方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitOfWork::getScheduledEntityInsertions方法的具体用法?PHP UnitOfWork::getScheduledEntityInsertions怎么用?PHP UnitOfWork::getScheduledEntityInsertions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork::getScheduledEntityInsertions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onFlush

 /**
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $this->initializeFromEventArgs($args);
     $entities = array_merge($this->uow->getScheduledEntityInsertions(), $this->uow->getScheduledEntityDeletions(), $this->uow->getScheduledEntityUpdates());
     /** @var Opportunity[] $entities */
     $entities = array_filter($entities, function ($entity) {
         return 'OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity' === ClassUtils::getClass($entity);
     });
     foreach ($entities as $entity) {
         if (!$entity->getId() && $this->isValuable($entity)) {
             // handle creation, just add to prev lifetime value and recalculate change set
             $b2bCustomer = $entity->getCustomer();
             $b2bCustomer->setLifetime($b2bCustomer->getLifetime() + $entity->getCloseRevenue());
             $this->scheduleUpdate($b2bCustomer);
             $this->uow->computeChangeSet($this->em->getClassMetadata(ClassUtils::getClass($b2bCustomer)), $b2bCustomer);
         } elseif ($this->uow->isScheduledForDelete($entity) && $this->isValuable($entity)) {
             $this->scheduleUpdate($entity->getCustomer());
         } elseif ($this->uow->isScheduledForUpdate($entity)) {
             // handle update
             $changeSet = $this->uow->getEntityChangeSet($entity);
             if ($this->isChangeSetValuable($changeSet)) {
                 if (!empty($changeSet['customer']) && $changeSet['customer'][0] instanceof B2bCustomer && B2bCustomerRepository::VALUABLE_STATUS === $this->getOldStatus($entity, $changeSet)) {
                     // handle change of b2b customer
                     $this->scheduleUpdate($changeSet['customer'][0]);
                 }
                 if ($this->isValuable($entity, isset($changeSet['closeRevenue'])) || B2bCustomerRepository::VALUABLE_STATUS === $this->getOldStatus($entity, $changeSet) && $entity->getCustomer()) {
                     $this->scheduleUpdate($entity->getCustomer());
                 }
             }
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:35,代码来源:B2bCustomerLifetimeListener.php

示例2: onFlush

 /**
  * @param OnFlushEventArgs $event
  */
 public function onFlush(OnFlushEventArgs $event)
 {
     $this->em = $event->getEntityManager();
     $this->uow = $this->em->getUnitOfWork();
     foreach ($this->uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof Ticket) {
             $this->startAutoReply($entity);
         }
     }
 }
开发者ID:northdakota,项目名称:diamantedesk-application,代码行数:13,代码来源:ArticleAutoReplyServiceImpl.php

示例3: onFlush

 public function onFlush(OnFlushEventArgs $e)
 {
     $this->init($e);
     foreach ($this->uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof RoundedEntityInterface) {
             $entity->setRound($this->round);
             $this->uow->recomputeSingleEntityChangeSet($this->em->getClassMetadata(get_class($entity)), $entity);
         }
     }
     //$this->uow->computeChangeSets();
 }
开发者ID:RinWorld,项目名称:Ponzi-1,代码行数:11,代码来源:RoundListener.php

示例4: getChangedTrackedEntities

 /**
  * @return array|CustomerIdentityInterface[]
  */
 protected function getChangedTrackedEntities()
 {
     $entities = array_merge($this->uow->getScheduledEntityInsertions(), $this->uow->getScheduledEntityDeletions(), $this->uow->getScheduledEntityUpdates());
     $collections = array_merge($this->uow->getScheduledCollectionDeletions(), $this->uow->getScheduledCollectionUpdates());
     /** @var PersistentCollection $collectionToChange */
     foreach ($collections as $collectionToChange) {
         $entities = array_merge($entities, $collectionToChange->unwrap()->toArray());
     }
     return array_filter($entities, function ($entity) {
         return $entity instanceof CustomerIdentityInterface && array_key_exists(ClassUtils::getClass($entity), $this->customerIdentities);
     });
 }
开发者ID:rodolfobandeira,项目名称:crm,代码行数:15,代码来源:ChannelDoctrineListener.php

示例5: executeEvents

 /**
  * @internal
  * @return bool
  * @author Andreas Glaser
  */
 protected function executeEvents()
 {
     $reRun = false;
     foreach ($this->unitOfWork->getScheduledEntityInsertions() as $hash => $entity) {
         if (array_key_exists($hash, $this->processedEntities['persist'])) {
             continue;
         }
         $this->initPersist($entity, true);
         $this->processRecalculationQueue();
         $reRun = true;
     }
     foreach ($this->unitOfWork->getScheduledEntityUpdates() as $hash => $entity) {
         if (array_key_exists($hash, $this->processedEntities['update']) || array_key_exists($hash, $this->processedEntities['remove'])) {
             continue;
         }
         $this->initUpdate($entity, true);
         $this->processRecalculationQueue();
         $reRun = true;
     }
     foreach ($this->unitOfWork->getScheduledEntityDeletions() as $hash => $entity) {
         if (array_key_exists($hash, $this->processedEntities['remove'])) {
             continue;
         }
         $this->initRemove($entity, true);
         $this->processRecalculationQueue();
         $reRun = true;
     }
     return $reRun;
 }
开发者ID:andreas-glaser,项目名称:dc-event-bundle,代码行数:34,代码来源:DCEventListener.php

示例6: getChangedOrders

 /**
  * @param UnitOfWork $uow
  * @return array|Order[]
  */
 protected function getChangedOrders(UnitOfWork $uow)
 {
     $entities = array_merge($uow->getScheduledEntityInsertions(), $uow->getScheduledEntityDeletions(), $uow->getScheduledEntityUpdates());
     $collections = array_merge($uow->getScheduledCollectionDeletions(), $uow->getScheduledCollectionUpdates());
     /** @var PersistentCollection $collectionToChange */
     foreach ($collections as $collectionToChange) {
         $entities = array_merge($entities, $collectionToChange->unwrap()->toArray());
     }
     return array_filter($entities, function ($entity) {
         return $this->isOrderValid($entity);
     });
 }
开发者ID:antrampa,项目名称:crm,代码行数:16,代码来源:OrderListener.php

示例7: onFlush

 /**
  * @param OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $this->em = $eventArgs->getEntityManager();
     $this->unitOfWork = $this->em->getUnitOfWork();
     // New localization creation, could contain children already, need to recurse into children
     foreach ($this->unitOfWork->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof PageLocalization) {
             $this->pageLocalizationChange($entity, true);
         }
     }
     // Page path is not set from inserts, updates only
     foreach ($this->unitOfWork->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof PageLocalization) {
             $this->pageLocalizationChange($entity);
         }
         // this should be covered by the move trigger
         if ($entity instanceof Page) {
             // Run for all children, every locale
             $this->pageChange($entity);
         }
     }
 }
开发者ID:sitesupra,项目名称:sitesupra,代码行数:25,代码来源:PagePathGeneratorListener.php

示例8: onFlush

 /**
  * Main method: get all entities scheduled to be inserted, updated or deleted,
  * then remove duplicates and call setTags() method
  *
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $this->em = $args->getEntityManager();
     $this->uow = $this->em->getUnitOfWork();
     $entities = $this->uow->getScheduledEntityInsertions();
     foreach ($this->uow->getScheduledEntityUpdates() as $key => $entity) {
         if (!in_array($entity, $entities)) {
             $entities[$key] = $entity;
         }
     }
     foreach ($entities as $entity) {
         if ($entity instanceof TaggableInterface) {
             $this->setTags($entity, true);
         }
     }
     if ($this->purge) {
         foreach ($this->uow->getScheduledEntityDeletions() as $key => $entity) {
             if ($entity instanceof TaggableInterface) {
                 $this->purgeTags($entity);
             }
         }
     }
 }
开发者ID:jinfollc,项目名称:BeelabTagBundle,代码行数:29,代码来源:TagSubscriber.php

示例9: testOnFlush

 /**
  * @param $changeset The changeset for the entity
  * @param $expectedFields List of filds which should be updated/set
  *
  * @dataProvider provideLifecycle
  */
 public function testOnFlush($changeset, $expectedFields)
 {
     $entity = $this->userBlameObject->reveal();
     $this->unitOfWork->getScheduledEntityInsertions()->willReturn([$entity]);
     $this->unitOfWork->getScheduledEntityUpdates()->willReturn([]);
     $this->entityManager->getClassMetadata(get_class($entity))->willReturn($this->classMetadata);
     $this->unitOfWork->getEntityChangeSet($this->userBlameObject->reveal())->willReturn($changeset);
     foreach (['creator', 'changer'] as $field) {
         $prophecy = $this->classMetadata->setFieldValue($this->userBlameObject->reveal(), $field, $this->user->reveal());
         if (in_array($field, $expectedFields)) {
             $prophecy->shouldBeCalled();
             continue;
         }
         $prophecy->shouldNotBeCalled();
     }
     if (count($expectedFields)) {
         $this->unitOfWork->recomputeSingleEntityChangeSet($this->classMetadata->reveal(), $this->userBlameObject->reveal())->shouldBeCalled();
     }
     $this->subscriber->onFlush($this->onFlushEvent->reveal());
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:26,代码来源:UserBlameSubscriberTest.php

示例10: onFlush

 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $this->em = $eventArgs->getEntityManager();
     $this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy();
     $this->conn = $this->em->getConnection();
     $this->uow = $this->em->getUnitOfWork();
     $this->platform = $this->conn->getDatabasePlatform();
     $this->revisionId = null;
     // reset revision
     $processedEntities = array();
     foreach ($this->uow->getScheduledEntityDeletions() as $entity) {
         //doctrine is fine deleting elements multiple times. We are not.
         $hash = $this->getHash($entity);
         if (in_array($hash, $processedEntities)) {
             continue;
         }
         $processedEntities[] = $hash;
         $class = $this->em->getClassMetadata(get_class($entity));
         if (!$this->metadataFactory->isAudited($class->name)) {
             continue;
         }
         $entityData = array_merge($this->getOriginalEntityData($entity), $this->uow->getEntityIdentifier($entity));
         $this->saveRevisionEntityData($class, $entityData, 'DEL');
     }
     foreach ($this->uow->getScheduledEntityInsertions() as $entity) {
         if (!$this->metadataFactory->isAudited(get_class($entity))) {
             continue;
         }
         $this->extraUpdates[spl_object_hash($entity)] = $entity;
     }
     foreach ($this->uow->getScheduledEntityUpdates() as $entity) {
         if (!$this->metadataFactory->isAudited(get_class($entity))) {
             continue;
         }
         $this->extraUpdates[spl_object_hash($entity)] = $entity;
     }
 }
开发者ID:Soullivaneuh,项目名称:EntityAudit,代码行数:37,代码来源:LogRevisionsListener.php

示例11: onInsert

 /**
  * @param callable $callback    Callback
  * @param string   $entityClass Entity class filter
  *
  * @return AbstractOnFlushListener
  */
 protected function onInsert(callable $callback, $entityClass = null)
 {
     $this->checkIfInitialized();
     return $this->processEntities($this->uow->getScheduledEntityInsertions(), self::OPERATION_INSERT, $callback, $entityClass);
 }
开发者ID:darvinstudio,项目名称:darvin-utils,代码行数:11,代码来源:AbstractOnFlushListener.php

示例12: getScheduledObjectInsertions

 /**
  * Get the scheduled object insertions from a UnitOfWork.
  *
  * @param \Doctrine\ORM\UnitOfWork $uow
  * @return array
  */
 public function getScheduledObjectInsertions(UnitOfWork $uow)
 {
     return $uow->getScheduledEntityInsertions();
 }
开发者ID:norzechowicz,项目名称:doctrine-extensions,代码行数:10,代码来源:ORM.php

示例13: updateRouting

 /**
  * Schedule updates for routing
  *
  * @param EntityManager $em
  * @param UnitOfWork    $uow
  */
 protected function updateRouting(EntityManager $em, UnitOfWork $uow)
 {
     // 302 old routes to the new 200
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof Node) {
             $changeSet = $uow->getEntityChangeSet($entity);
             $oldRoute = $entity->getRoute();
             // Check if we have a route. If not, create on and continue
             if (!$oldRoute instanceof Route) {
                 // create the new route
                 $oldRoute = $this->getNodeRoute($entity);
                 $entity->setRoute($oldRoute);
                 $this->computeChangeSet($em, $oldRoute);
                 $this->recomputeSingleEntityChangeSet($em, $entity);
             }
             // Check if the route has been manually updated
             $newRoute = $this->getNodeRoute($entity);
             // if the route changed, update it
             if ($newRoute->getPath() !== $oldRoute->getPath()) {
                 // create the new route entity
                 $entity->setRoute($newRoute);
                 $this->computeChangeSet($em, $newRoute);
                 // set any old route to redirect to the new route
                 $this->redirectRoute($oldRoute, $newRoute->getPath());
                 $this->recomputeSingleEntityChangeSet($em, $oldRoute);
             }
             if (isset($changeSet['deletedOn'])) {
                 if ($changeSet['deletedOn'] instanceof \DateTime) {
                     // delete
                     $this->deletedRoute($oldRoute);
                     $this->recomputeSingleEntityChangeSet($em, $oldRoute);
                 } else {
                     // un-delete
                     $newRoute = $this->getNodeRoute($entity);
                     $entity->setRoute($newRoute);
                     $uow->scheduleForDelete($oldRoute);
                     $this->computeChangeSet($em, $newRoute);
                     $this->recomputeSingleEntityChangeSet($em, $oldRoute);
                 }
             }
             $em->persist($entity);
             $this->recomputeSingleEntityChangeSet($em, $entity);
         }
     }
     // create 200 routes for new nodes
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof Node) {
             $route = $this->getNodeRoute($entity);
             $em->persist($route);
             $this->computeChangeSet($em, $route);
             $entity->setRoute($route);
             $this->recomputeSingleEntityChangeSet($em, $entity);
         }
     }
 }
开发者ID:andythorne,项目名称:sandbox,代码行数:61,代码来源:NodeEventListener.php

示例14: createEmailAddressData

 /**
  * Creates data
  *
  * @param UnitOfWork $uow
  * @return array
  */
 public function createEmailAddressData(UnitOfWork $uow)
 {
     return ['updates' => array_map(function ($entity) use($uow) {
         return ['entity' => $entity, 'changeSet' => $uow->getEntityChangeSet($entity)];
     }, array_filter(array_merge($uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates()), $this->getEntityFilter())), 'deletions' => array_filter($uow->getScheduledEntityDeletions(), $this->getEntityFilter())];
 }
开发者ID:startupz,项目名称:platform-1,代码行数:12,代码来源:EmailOwnerManager.php

示例15: onFlush

 public function onFlush(OnFlushEventArgs $e)
 {
     $this->init($e);
     if ($this->stats) {
         foreach ($this->uow->getScheduledEntityInsertions() as $entity) {
             if ($entity instanceof Deposit) {
                 // deposit arrived
                 if ($entity->isConfirmed()) {
                     // it is confirmed
                     $this->addConfirmedDeposit($entity);
                 } else {
                     // it is pending
                     $entity->getAccount()->addTotalPendingDeposit($entity->getAmount());
                     $this->stats->addTotalPendingDeposit($entity->getAmount());
                 }
                 $this->stats->setLastDeposit($entity->getReceivedTime());
                 $this->recoumputeChanges($entity->getAccount());
             }
             if ($entity instanceof PayoutTx) {
                 // transaction has just been sent
                 $this->stats->addTotalTxFees($entity->getTxFee() * -1);
             }
         }
         foreach ($this->uow->getScheduledEntityUpdates() as $entity) {
             if ($entity instanceof Deposit) {
                 $changes = $this->uow->getEntityChangeSet($entity);
                 if (isset($changes['confirmed'])) {
                     $oldConfirmed = $changes['confirmed'][0];
                     $newConfirmed = $changes['confirmed'][1];
                     if (!$oldConfirmed && $newConfirmed) {
                         // subtract pending if not referrer
                         $this->stats->subtractTotalPendingDeposit($entity->getAmount());
                         $entity->getAccount()->subtractTotalPendingDeposit($entity->getAmount());
                         // add confirmed
                         $this->addConfirmedDeposit($entity);
                         $this->recoumputeChanges($entity->getAccount());
                     }
                 }
             }
             if ($entity instanceof Payout) {
                 $changes = $this->uow->getEntityChangeSet($entity);
                 if (isset($changes['paid'])) {
                     $oldPaid = $changes['paid'][0];
                     $newPaid = $changes['paid'][1];
                     if (!$oldPaid && $newPaid) {
                         if ($entity->isDefaultPayout() || $entity->isRemainingFundsReturn() || $entity->isLastPayout()) {
                             $this->stats->addTotalPayout($entity->getAmount());
                             $entity->getAccount()->addTotalPayout($entity->getAmount());
                             if ($entity->isDefaultPayout()) {
                                 $this->stats->setLastPayout($entity->getPaidOutTime());
                             }
                         } elseif ($entity->isReferrerPayout()) {
                             $this->stats->addTotalReferralPayout($entity->getAmount());
                             $entity->getAccount()->addTotalReferralPayout($entity->getAmount());
                         }
                         if (!$entity->isLastAdminPayout()) {
                             $this->recoumputeChanges($entity->getAccount());
                         }
                         $this->stats->addTotalFees($entity->getFee());
                     }
                 }
             }
         }
         $this->recoumputeChanges($this->stats);
         $this->uow->computeChangeSets();
     }
 }
开发者ID:RinWorld,项目名称:Ponzi-1,代码行数:67,代码来源:StatsListener.php


注:本文中的Doctrine\ORM\UnitOfWork::getScheduledEntityInsertions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。