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


PHP UnitOfWork::scheduleExtraUpdate方法代码示例

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


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

示例1: setSourceModificationDate

 /**
  * Updates modification date for a source.
  *
  * @param SourceInterface $source
  * @param UnitOfWork      $uow
  */
 protected function setSourceModificationDate(SourceInterface $source, UnitOfWork $uow)
 {
     $uow->scheduleExtraUpdate($source, ['datetimeModified' => [0 => $source->getDatetimeModified(), 1 => new \DateTime()]]);
 }
开发者ID:treehouselabs,项目名称:io-bundle,代码行数:10,代码来源:SourceModificationListener.php

示例2: updateField

 /**
  * Updates a field
  *
  * @param ORM\UnitOfWork $uow
  * @param mixed $object
  * @param ORM\Mapping\ClassMetadata $classMetadata
  * @param string $field
  */
 private function updateField(ORM\UnitOfWork $uow, $object, ORM\Mapping\ClassMetadata $classMetadata, $field)
 {
     $property = $classMetadata->getReflectionProperty($field);
     $oldValue = $property->getValue($object);
     $newValue = $this->getDateValue($classMetadata, $field);
     $property->setValue($object, $newValue);
     $uow->propertyChanged($object, $field, $oldValue, $newValue);
     $uow->scheduleExtraUpdate($object, [$field => [$oldValue, $newValue]]);
 }
开发者ID:iPublikuj,项目名称:doctrine-timestampable,代码行数:17,代码来源:TimestampableSubscriber.php

示例3: onFlushForUpdates

 /**
  * Flush for update
  *
  * @param object $entity
  * @param \Doctrine\ORM\EntityManager $entityManager
  * @param \Doctrine\ORM\UnitOfWork $unitOfWork
  */
 protected function onFlushForUpdates(&$entity, EntityManager &$entityManager, UnitOfWork &$unitOfWork)
 {
     $className = get_class($entity);
     $this->initializeAnnotationsForEntity($className);
     if (count(self::$storedProperties[$className]['annotations']) > 0) {
         foreach (self::$storedProperties[$className]['annotations'] as $propertyName => &$annotations) {
             /* @var $annotation Traceable */
             foreach ($annotations as $annotation) {
                 $run = $annotation->on === 'update';
                 if ($annotation->on === 'change') {
                     $changeSet = $unitOfWork->getEntityChangeSet($entity);
                     if (isset($changeSet[$annotation->field])) {
                         $type = $this->getPropertyType($className, $annotation->field);
                         $values = $annotation->getFieldValues($type, $entity);
                         $run = count($values) === 0 || in_array($changeSet[$annotation->field][1], $values);
                     }
                 }
                 if ($run) {
                     list($oldValue, $value) = $this->updateEntityPropertyValue($entity, $className, $propertyName, $annotation);
                     $entityManager->persist($entity);
                     $unitOfWork->propertyChanged($entity, $propertyName, $oldValue, $value);
                     $unitOfWork->scheduleExtraUpdate($entity, array($propertyName => array($oldValue, $value)));
                     break;
                 }
             }
         }
     }
 }
开发者ID:sixty-nine,项目名称:CDSRC.Libraries,代码行数:35,代码来源:EventListener.php

示例4: onFlush

 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     if (!$this->active) {
         return;
     }
     // Clear updateData
     $this->updateData = $this->extraUpdates = array();
     $this->em = $eventArgs->getEntityManager();
     $this->conn = $this->em->getConnection();
     $this->uow = $this->em->getUnitOfWork();
     $this->platform = $this->conn->getDatabasePlatform();
     $this->revisionId = null;
     // reset revision
     $this->draft = false;
     $processedEntities = array();
     foreach ($this->uow->getScheduledEntityDeletions() as $entity) {
         if (!$this->annotationReader->isRevised(get_class($entity), true)) {
             continue;
         }
         //doctrine is fine deleting elements multiple times. We are not.
         $hash = $this->getHash($entity);
         if (in_array($hash, $processedEntities)) {
             continue;
         }
         $processedEntities[] = $hash;
         $this->extraUpdates[spl_object_hash($entity)] = $entity;
         $persister = $this->uow->getEntityPersister(get_class($entity));
         $this->updateData[spl_object_hash($entity)] = $this->prepareUpdateData($persister, $entity);
         $entityData = array_merge($this->getOriginalEntityData($entity), $this->uow->getEntityIdentifier($entity));
         $this->saveRevisionEntityData($this->em->getClassMetadata(get_class($entity)), $entityData, 'DEL');
         if ($this->annotationReader->isDraft($entity) && $entity->isDraft()) {
             $this->resetRevisedData($entity);
             $this->setRevisionInfo($entity);
             $persister = $this->uow->getEntityPersister(get_class($entity));
             $this->updateData[spl_object_hash($entity)] = $this->prepareUpdateData($persister, $entity);
             $fieldName = 'deletedAt';
             $reflProp = new \ReflectionProperty($entity, $fieldName);
             $reflProp->setAccessible(true);
             $oldValue = $reflProp->getValue($entity);
             $reflProp->setValue($entity, null);
             $this->uow->scheduleExtraUpdate($entity, array($fieldName => array($oldValue, null)));
         }
         if (isset($this->softDeletes[spl_object_hash($entity)])) {
             $this->em->persist($entity);
         }
     }
     foreach ($this->uow->getScheduledEntityInsertions() as $entity) {
         if (!$this->annotationReader->isRevised(get_class($entity), true)) {
             continue;
         }
         $this->setRevisionInfo($entity);
         $this->extraUpdates[spl_object_hash($entity)] = $entity;
         $persister = $this->uow->getEntityPersister(get_class($entity));
         $this->updateData[spl_object_hash($entity)] = $this->prepareUpdateData($persister, $entity);
         if ($this->annotationReader->isDraft($entity) && $entity->isDraft()) {
             $this->insertDrafts[spl_object_hash($entity)] = $entity;
             $this->resetRevisedData($entity);
             $this->uow->recomputeSingleEntityChangeSet($this->em->getClassMetadata(get_class($entity)), $entity);
         }
     }
     foreach ($this->uow->getScheduledEntityUpdates() as $entity) {
         if (!$this->annotationReader->isRevised(get_class($entity), true)) {
             continue;
         }
         $this->setRevisionInfo($entity);
         $this->extraUpdates[spl_object_hash($entity)] = $entity;
         $persister = $this->uow->getEntityPersister(get_class($entity));
         $this->updateData[spl_object_hash($entity)] = $this->prepareUpdateData($persister, $entity);
         if ($this->annotationReader->isDraft($entity) && $entity->isDraft()) {
             $this->resetRevisedData($entity);
         }
     }
 }
开发者ID:opifer,项目名称:revisions,代码行数:73,代码来源:RevisionListener.php


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