本文整理汇总了PHP中Doctrine\ORM\UnitOfWork::isScheduledForUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitOfWork::isScheduledForUpdate方法的具体用法?PHP UnitOfWork::isScheduledForUpdate怎么用?PHP UnitOfWork::isScheduledForUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork::isScheduledForUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
}
}
}
示例2: onFlush
/**
* @param OnFlushEventArgs $args
*/
public function onFlush(OnFlushEventArgs $args)
{
$this->initializeFromEventArgs($args);
$entities = $this->getChangedTrackedEntities();
foreach ($entities as $entity) {
$className = ClassUtils::getClass($entity);
if ($this->uow->isScheduledForUpdate($entity)) {
$this->checkAndUpdate($entity, $this->uow->getEntityChangeSet($entity));
} else {
$this->scheduleUpdate($className, $entity->getAccount(), $entity->getDataChannel());
}
}
}