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


PHP UnitOfWork::isScheduledForUpdate方法代码示例

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


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

示例1:

 function it_schedules_owning_document_for_update_when_setting_element_by_key_in_the_collection(MongoDBODMUnitOfWork $uow, DocumentStub $document, ObjectRepository $repository, ClassMetadata $classMetadata, EntityStub $entity4, EntityStub $entity8, EntityStub $entity15, EntityStub $newEntity)
 {
     $classMetadata->getIdentifier()->willReturn(['id']);
     $repository->findBy(['id' => [4, 8, 15]])->willReturn([$entity4, $entity8, $entity15]);
     $uow->getDocumentState($document)->willReturn(MongoDBODMUnitOfWork::STATE_MANAGED);
     $uow->isScheduledForUpdate($document)->willReturn(false);
     $uow->scheduleForUpdate($document)->shouldBeCalled();
     $this->setOwner($document);
     $this->set(2, $newEntity);
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:10,代码来源:ReferencedCollectionSpec.php

示例2: guardMissingShardKey

 /**
  * If the document is new, ignore shard key field value, otherwise throw an exception.
  * Also, shard key field should be present in actual document data.
  *
  * @param object $document
  * @param string $shardKeyField
  * @param array  $actualDocumentData
  *
  * @throws MongoDBException
  */
 private function guardMissingShardKey($document, $shardKeyField, $actualDocumentData)
 {
     $dcs = $this->uow->getDocumentChangeSet($document);
     $isUpdate = $this->uow->isScheduledForUpdate($document);
     $fieldMapping = $this->class->getFieldMappingByDbFieldName($shardKeyField);
     $fieldName = $fieldMapping['fieldName'];
     if ($isUpdate && isset($dcs[$fieldName]) && $dcs[$fieldName][0] != $dcs[$fieldName][1]) {
         throw MongoDBException::shardKeyFieldCannotBeChanged($shardKeyField, $this->class->getName());
     }
     if (!isset($actualDocumentData[$fieldName])) {
         throw MongoDBException::shardKeyFieldMissing($shardKeyField, $this->class->getName());
     }
 }
开发者ID:dominium,项目名称:mongodb-odm,代码行数:23,代码来源:DocumentPersister.php

示例3: getShardKeyQuery

 /**
  * @param $document
  * @return array
  * @throws MongoDBException
  */
 public function getShardKeyQuery($document)
 {
     $shardKeysQueryPart = array();
     $dcs = $this->uow->getDocumentChangeSet($document);
     $data = $this->uow->getDocumentActualData($document);
     $md = $this->dm->getMetadataFactory()->getMetadataFor(get_class($document));
     $keys = $md->shardKeys;
     $fieldMappings = $this->dm->getClassMetadata(get_class($document))->fieldMappings;
     foreach ($keys as $key) {
         if ($key !== 'id') {
             $queryKey = $fieldMappings[$key]['name'];
         } else {
             $queryKey = '_id';
         }
         //If the document is new, we can ignore shard key value, otherwise throw exception
         $isUpdate = $this->uow->isScheduledForUpdate($document);
         if ($isUpdate && isset($dcs[$key]) && $dcs[$key][0] !== null && $dcs[$key][0] != $dcs[$key][1] && (!isset($options['upsert']) || isset($options['upsert']) && $options['upsert'] === true)) {
             throw MongoDBException::shardKeyChange($key);
         }
         if (!isset($data[$key])) {
             throw MongoDBException::shardKeyMissing($key);
         }
         $new = $data[$key];
         $mapping = $fieldMappings[$key];
         // @Field, @String, @Date, etc.
         if (!isset($mapping['association'])) {
             if (isset($new) || $mapping['nullable'] === true) {
                 $shardKeysQueryPart[$queryKey] = is_null($new) ? null : Type::getType($mapping['type'])->convertToDatabaseValue($new);
             }
             // @ReferenceOne
         } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isOwningSide']) {
             if (isset($new) || $mapping['nullable'] === true) {
                 $shardKeysQueryPart[$queryKey] = is_null($new) ? null : $this->pb->prepareReferencedDocumentValue($mapping, $new);
             }
             // @ReferenceMany
         } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_MANY) {
             // Do nothing right now
         }
     }
     return $shardKeysQueryPart;
 }
开发者ID:backplane,项目名称:mongodb-odm,代码行数:46,代码来源:DocumentPersister.php


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