• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mapping\ClassMetadata类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fromDocument

 /**
  * @param ClassMetadata $classMetadata
  * @return $this
  *
  * @throws MappingException
  */
 private function fromDocument(ClassMetadata $classMetadata)
 {
     if ($classMetadata->isSharded()) {
         throw MappingException::cannotUseShardedCollectionInOutStage($classMetadata->name);
     }
     return parent::out($classMetadata->getCollection());
 }
开发者ID:doctrine,项目名称:mongodb-odm,代码行数:13,代码来源:Out.php


示例2: fromReference

 /**
  * @param string $fieldName
  * @return $this
  * @throws MappingException
  */
 private function fromReference($fieldName)
 {
     if (!$this->class->hasReference($fieldName)) {
         MappingException::referenceMappingNotFound($this->class->name, $fieldName);
     }
     $referenceMapping = $this->class->getFieldMapping($fieldName);
     $targetMapping = $this->dm->getClassMetadata($referenceMapping['targetDocument']);
     parent::from($targetMapping->getCollection());
     if ($referenceMapping['isOwningSide']) {
         if ($referenceMapping['storeAs'] !== ClassMetadataInfo::REFERENCE_STORE_AS_ID) {
             throw MappingException::cannotLookupNonIdReference($this->class->name, $fieldName);
         }
         $this->foreignField('_id')->localField($referenceMapping['name']);
     } else {
         if (isset($referenceMapping['repositoryMethod'])) {
             throw MappingException::repositoryMethodLookupNotAllowed($this->class->name, $fieldName);
         }
         $mappedByMapping = $targetMapping->getFieldMapping($referenceMapping['mappedBy']);
         if ($mappedByMapping['storeAs'] !== ClassMetadataInfo::REFERENCE_STORE_AS_ID) {
             throw MappingException::cannotLookupNonIdReference($this->class->name, $fieldName);
         }
         $this->localField('_id')->foreignField($mappedByMapping['name']);
     }
     return $this;
 }
开发者ID:doctrine,项目名称:mongodb-odm,代码行数:30,代码来源:Lookup.php


示例3: createResourceRepository

 /**
  * @param string                 $class
  * @param DocumentManager        $documentManager
  * @param ClassMetadata          $metadata
  * @param ResourceInterface|null $resource
  *
  * @return ObjectRepository
  */
 protected function createResourceRepository($class, DocumentManager $documentManager, ClassMetadata $metadata, ResourceInterface $resource = null)
 {
     if ($resource !== null && is_a($class, BaseRepositoryInterface::class, true)) {
         return new $class($documentManager, $documentManager->getUnitOfWork(), $metadata, $resource);
     }
     return parent::createRepository($documentManager, $metadata->getName());
 }
开发者ID:blazarecki,项目名称:lug,代码行数:15,代码来源:RepositoryFactory.php


示例4: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $class)
 {
     if ($class->getReflectionClass()->isSubclassOf('Gedmo\\Translatable\\Document\\MappedSuperclass\\AbstractPersonalTranslation')) {
         throw new \Gedmo\Exception\UnexpectedValueException('This repository is useless for personal translations');
     }
     parent::__construct($dm, $uow, $class);
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:10,代码来源:TranslationRepository.php


示例5: getQueryArray

 protected function getQueryArray(ClassMetadata $metadata, $document, $path)
 {
     $class = $metadata->name;
     $field = $this->getFieldNameFromPropertyPath($path);
     if (!isset($metadata->fieldMappings[$field])) {
         throw new \LogicException('Mapping for \'' . $path . '\' doesn\'t exist for ' . $class);
     }
     $mapping = $metadata->fieldMappings[$field];
     if (isset($mapping['reference']) && $mapping['reference']) {
         throw new \LogicException('Cannot determine uniqueness of referenced document values');
     }
     switch ($mapping['type']) {
         case 'one':
             // TODO: implement support for embed one documents
         // TODO: implement support for embed one documents
         case 'many':
             // TODO: implement support for embed many documents
             throw new \RuntimeException('Not Implemented.');
         case 'hash':
             $value = $metadata->getFieldValue($document, $mapping['fieldName']);
             return array($path => $this->getFieldValueRecursively($path, $value));
         case 'collection':
             return array($mapping['fieldName'] => array('$in' => $metadata->getFieldValue($document, $mapping['fieldName'])));
         default:
             return array($mapping['fieldName'] => $metadata->getFieldValue($document, $mapping['fieldName']));
     }
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:27,代码来源:UniqueValidator.php


示例6: hydrate

 /**
  * Hydrate array of MongoDB document data into the given document object
  * based on the mapping information provided in the ClassMetadata instance.
  *
  * @param ClassMetadata $metadata  The ClassMetadata instance for mapping information.
  * @param string $document  The document object to hydrate the data into.
  * @param array $data The array of document data.
  * @return array $values The array of hydrated values.
  */
 public function hydrate(ClassMetadata $metadata, $document, $data)
 {
     $values = array();
     foreach ($metadata->fieldMappings as $mapping) {
         if (!isset($data[$mapping['fieldName']])) {
             continue;
         }
         if (isset($mapping['embedded'])) {
             $embeddedMetadata = $this->_dm->getClassMetadata($mapping['targetDocument']);
             $embeddedDocument = $embeddedMetadata->newInstance();
             if ($mapping['type'] === 'many') {
                 $documents = new ArrayCollection();
                 foreach ($data[$mapping['fieldName']] as $docArray) {
                     $doc = clone $embeddedDocument;
                     $this->hydrate($embeddedMetadata, $doc, $docArray);
                     $documents->add($doc);
                 }
                 $metadata->setFieldValue($document, $mapping['fieldName'], $documents);
                 $value = $documents;
             } else {
                 $value = clone $embeddedDocument;
                 $this->hydrate($embeddedMetadata, $value, $data[$mapping['fieldName']]);
                 $metadata->setFieldValue($document, $mapping['fieldName'], $value);
             }
         } elseif (isset($mapping['reference'])) {
             $targetMetadata = $this->_dm->getClassMetadata($mapping['targetDocument']);
             $targetDocument = $targetMetadata->newInstance();
             $value = isset($data[$mapping['fieldName']]) ? $data[$mapping['fieldName']] : null;
             if ($mapping['type'] === 'one' && isset($value['$id'])) {
                 $id = (string) $value['$id'];
                 $proxy = $this->_dm->getReference($mapping['targetDocument'], $id);
                 $metadata->setFieldValue($document, $mapping['fieldName'], $proxy);
             } elseif ($mapping['type'] === 'many' && (is_array($value) || $value instanceof Collection)) {
                 $documents = new PersistentCollection($this->_dm, $targetMetadata, new ArrayCollection());
                 $documents->setInitialized(false);
                 foreach ($value as $v) {
                     $id = (string) $v['$id'];
                     $proxy = $this->_dm->getReference($mapping['targetDocument'], $id);
                     $documents->add($proxy);
                 }
                 $metadata->setFieldValue($document, $mapping['fieldName'], $documents);
             }
         } else {
             $value = $data[$mapping['fieldName']];
             $value = Type::getType($mapping['type'])->convertToPHPValue($value);
             $metadata->setFieldValue($document, $mapping['fieldName'], $value);
         }
         if (isset($value)) {
             $values[$mapping['fieldName']] = $value;
         }
     }
     if (isset($data['_id'])) {
         $metadata->setIdentifierValue($document, (string) $data['_id']);
     }
     return $values;
 }
开发者ID:poulikov,项目名称:mongodb-odm,代码行数:65,代码来源:Hydrator.php


示例7: setCustomRepositoryClass

 /**
  * @param ClassMetadata $metadata
  */
 private function setCustomRepositoryClass(ClassMetadata $metadata)
 {
     try {
         $resourceMetadata = $this->resourceRegistry->getByClass($metadata->getName());
     } catch (\InvalidArgumentException $exception) {
         return;
     }
     if ($resourceMetadata->hasClass('repository')) {
         $metadata->setCustomRepositoryClass($resourceMetadata->getClass('repository'));
     }
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:14,代码来源:ODMRepositoryClassSubscriber.php


示例8: testCreateQueryBuilderForCollection

 public function testCreateQueryBuilderForCollection()
 {
     $this->classMetadata->expects($this->once())->method('getFieldNames')->will($this->returnValue([]));
     $this->classMetadata->expects($this->once())->method('getAssociationTargetClass')->with($this->identicalTo('translations'))->will($this->returnValue($translationClass = TranslationTest::class));
     $translationClassMetadata = $this->createClassMetadataMock();
     $translationClassMetadata->expects($this->once())->method('getFieldNames')->will($this->returnValue(['locale']));
     $this->documentManager->expects($this->once())->method('getClassMetadata')->with($this->identicalTo($translationClass))->will($this->returnValue($translationClassMetadata));
     $this->documentManager->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock()));
     $queryBuilder->expects($this->once())->method('field')->with($this->identicalTo('translations.locale'))->will($this->returnSelf());
     $this->localeContext->expects($this->once())->method('getLocales')->will($this->returnValue($locales = ['fr']));
     $this->localeContext->expects($this->once())->method('getFallbackLocale')->will($this->returnValue($fallbackLocale = 'en'));
     $queryBuilder->expects($this->once())->method('in')->with($this->identicalTo(array_merge($locales, [$fallbackLocale])))->will($this->returnSelf());
     $this->assertSame($queryBuilder, $this->translatableRepository->createQueryBuilderForCollection());
 }
开发者ID:blazarecki,项目名称:lug,代码行数:14,代码来源:TranslatableRepositoryTest.php


示例9: prepareQueryValue

 /**
  * Prepares a query value and converts the php value to the database value if it is an identifier.
  * It also handles converting $fieldName to the database name if they are different.
  *
  * @param string $fieldName
  * @param string $value
  * @return mixed $value
  */
 private function prepareQueryValue(&$fieldName, $value)
 {
     // Process "association.fieldName"
     if (strpos($fieldName, '.') !== false) {
         $e = explode('.', $fieldName);
         $mapping = $this->class->getFieldMapping($e[0]);
         if ($this->class->hasField($e[0])) {
             $name = $this->class->fieldMappings[$e[0]]['name'];
             if ($name !== $e[0]) {
                 $e[0] = $name;
             }
         }
         if (isset($mapping['targetDocument'])) {
             $targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
             if ($targetClass->hasField($e[1])) {
                 if ($targetClass->identifier === $e[1] || $e[1] === '$id') {
                     $fieldName = $e[0] . '.$id';
                     $value = $targetClass->getDatabaseIdentifierValue($value);
                 }
             }
         }
         // Process all non identifier fields
     } elseif ($this->class->hasField($fieldName) && !$this->class->isIdentifier($fieldName)) {
         $name = $this->class->fieldMappings[$fieldName]['name'];
         $mapping = $this->class->fieldMappings[$fieldName];
         if ($name !== $fieldName) {
             $fieldName = $name;
         }
         // Process identifier
     } elseif ($fieldName === $this->class->identifier || $fieldName === '_id') {
         $fieldName = '_id';
         $value = $this->class->getDatabaseIdentifierValue($value);
     }
     return $value;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:43,代码来源:DocumentPersister.php


示例10: getReferenceMapping

 /**
  * Gets reference mapping for current field from current class or its descendants.
  *
  * @return array
  * @throws MappingException
  */
 private function getReferenceMapping()
 {
     $mapping = null;
     try {
         $mapping = $this->class->getFieldMapping($this->currentField);
     } catch (MappingException $e) {
         if (empty($this->class->discriminatorMap)) {
             throw $e;
         }
         $foundIn = null;
         foreach ($this->class->discriminatorMap as $child) {
             $childClass = $this->dm->getClassMetadata($child);
             if ($childClass->hasAssociation($this->currentField)) {
                 if ($mapping !== null && $mapping !== $childClass->getFieldMapping($this->currentField)) {
                     throw MappingException::referenceFieldConflict($this->currentField, $foundIn->name, $childClass->name);
                 }
                 $mapping = $childClass->getFieldMapping($this->currentField);
                 $foundIn = $childClass;
             }
         }
         if ($mapping === null) {
             throw MappingException::mappingNotFoundInClassNorDescendants($this->class->name, $this->currentField);
         }
     }
     return $mapping;
 }
开发者ID:WillSkates,项目名称:mongodb-odm,代码行数:32,代码来源:Expr.php


示例11: prepareQueryValue

 /**
  * Prepares a query value and converts the php value to the database value if it is an identifier.
  * It also handles converting $fieldName to the database name if they are different.
  *
  * @param string $fieldName
  * @param string $value
  * @return mixed $value
  */
 private function prepareQueryValue(&$fieldName, $value)
 {
     // Process "association.fieldName"
     if (strpos($fieldName, '.') !== false) {
         $e = explode('.', $fieldName);
         $mapping = $this->class->getFieldMapping($e[0]);
         $name = $mapping['name'];
         if ($name !== $e[0]) {
             $e[0] = $name;
         }
         if (isset($mapping['targetDocument'])) {
             $targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
             if ($targetClass->hasField($e[1])) {
                 if ($targetClass->identifier === $e[1]) {
                     $e[1] = '$id';
                     if (is_array($value)) {
                         foreach ($value as $k => $v) {
                             $value[$k] = $targetClass->getDatabaseIdentifierValue($v);
                         }
                     } else {
                         $value = $targetClass->getDatabaseIdentifierValue($value);
                     }
                 } else {
                     $targetMapping = $targetClass->getFieldMapping($e[1]);
                     $targetName = $targetMapping['name'];
                     if ($targetName !== $e[1]) {
                         $e[1] = $targetName;
                     }
                 }
                 $fieldName = $e[0] . '.' . $e[1];
             }
         }
         // Process all non identifier fields
         // We only change the field names here to the mongodb field name used for persistence
     } elseif ($this->class->hasField($fieldName) && !$this->class->isIdentifier($fieldName)) {
         $name = $this->class->fieldMappings[$fieldName]['name'];
         $mapping = $this->class->fieldMappings[$fieldName];
         if ($name !== $fieldName) {
             $fieldName = $name;
         }
         // Process identifier
     } elseif ($this->class->hasField($fieldName) && $this->class->isIdentifier($fieldName) || $fieldName === '_id') {
         $fieldName = '_id';
         if (is_array($value)) {
             foreach ($value as $k => $v) {
                 if ($k[0] === '$' && is_array($v)) {
                     foreach ($v as $k2 => $v2) {
                         $value[$k][$k2] = $this->class->getDatabaseIdentifierValue($v2);
                     }
                 } else {
                     $value[$k] = $this->class->getDatabaseIdentifierValue($v);
                 }
             }
         } else {
             $value = $this->class->getDatabaseIdentifierValue($value);
         }
     }
     return $value;
 }
开发者ID:nextmotion,项目名称:mongodb-odm,代码行数:67,代码来源:DocumentPersister.php


示例12: testGetMetadataForSingleClass

 public function testGetMetadataForSingleClass()
 {
     // Self-made metadata
     $cm1 = new ClassMetadata('Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\TestDocument1');
     $cm1->setCollection('group');
     // Add a mapped field
     $cm1->mapField(array('fieldName' => 'name', 'type' => 'string'));
     // Add a mapped field
     $cm1->mapField(array('fieldName' => 'id', 'id' => true));
     // and a mapped association
     $cm1->mapOneEmbedded(array('fieldName' => 'other', 'targetDocument' => 'Other'));
     $cm1->mapOneEmbedded(array('fieldName' => 'association', 'targetDocument' => 'Other'));
     // SUT
     $cmf = new ClassMetadataFactoryTestSubject();
     $cmf->setMetadataFor('Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\TestDocument1', $cm1);
     // Prechecks
     $this->assertEquals(array(), $cm1->parentClasses);
     $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType);
     $this->assertTrue($cm1->hasField('name'));
     $this->assertEquals(4, count($cm1->fieldMappings));
     // Go
     $cm1 = $cmf->getMetadataFor('Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\TestDocument1');
     $this->assertEquals('group', $cm1->collection);
     $this->assertEquals(array(), $cm1->parentClasses);
     $this->assertTrue($cm1->hasField('name'));
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:26,代码来源:ClassMetadataFactoryTest.php


示例13: mapTranslation

 /**
  * Add mapping data to a translation entity.
  *
  * @param ClassMetadata $metadata
  */
 private function mapTranslation(ClassMetadata $metadata)
 {
     // In the case A -> B -> TranslationInterface, B might not have mapping defined as it
     // is probably defined in A, so in that case, we just return.
     if (!isset($this->configs[$metadata->name])) {
         return;
     }
     $metadata->mapManyToOne(array('fieldName' => 'translatable', 'targetEntity' => $this->configs[$metadata->name]['model'], 'inversedBy' => 'translations', 'joinColumns' => array(array('name' => 'translatable_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE', 'nullable' => false))));
     if (!$metadata->hasField('locale')) {
         $metadata->mapField(array('fieldName' => 'locale', 'type' => 'string', 'nullable' => false));
     }
     // Map unique index.
     $columns = array($metadata->getSingleAssociationJoinColumnName('translatable'), 'locale');
     if (!$this->hasUniqueConstraint($metadata, $columns)) {
         $constraints = isset($metadata->table['uniqueConstraints']) ? $metadata->table['uniqueConstraints'] : array();
         $constraints[$metadata->getTableName() . '_uniq_trans'] = array('columns' => $columns);
         $metadata->setPrimaryTable(array('uniqueConstraints' => $constraints));
     }
 }
开发者ID:eliberty,项目名称:SyliusTranslationBundle,代码行数:24,代码来源:ODMTranslatableListener.php


示例14: setAssociationMappings

 /**
  * @param ClassMetadataInfo $metadata
  * @param $configuration
  */
 private function setAssociationMappings(ClassMetadataInfo $metadata, $configuration)
 {
     foreach (class_parents($metadata->getName()) as $parent) {
         if (false === in_array($parent, $configuration->getMetadataDriverImpl()->getAllClassNames())) {
             continue;
         }
         $parentMetadata = new ClassMetadata($parent, $configuration->getNamingStrategy());
         // Wakeup Reflection
         $parentMetadata->wakeupReflection($this->getReflectionService());
         // Load Metadata
         $configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);
         if (false === $this->isResource($parentMetadata)) {
             continue;
         }
         if ($parentMetadata->isMappedSuperclass) {
             foreach ($parentMetadata->associationMappings as $key => $value) {
                 if ($this->hasRelation($value['association'])) {
                     $metadata->associationMappings[$key] = $value;
                 }
             }
         }
     }
 }
开发者ID:loic425,项目名称:Sylius,代码行数:27,代码来源:ODMMappedSuperClassSubscriber.php


示例15: remapAssociation

 /**
  * @param ClassMetadata $classMetadata
  * @param array $mapping
  */
 private function remapAssociation(ClassMetadata $classMetadata, array $mapping)
 {
     $newMapping = $this->resolveTargetDocuments[$mapping['targetDocument']];
     $newMapping = array_replace_recursive($mapping, $newMapping);
     $newMapping['fieldName'] = $mapping['fieldName'];
     // clear reference case of duplicate exception
     unset($classMetadata->fieldMappings[$mapping['fieldName']]);
     unset($classMetadata->associationMappings[$mapping['fieldName']]);
     switch ($mapping['association']) {
         case ClassMetadata::REFERENCE_ONE:
             $classMetadata->mapOneReference($newMapping);
             break;
         case ClassMetadata::REFERENCE_MANY:
             $classMetadata->mapManyReference($newMapping);
             break;
         case ClassMetadata::EMBED_ONE:
             $classMetadata->mapOneEmbedded($newMapping);
             break;
         case ClassMetadata::EMBED_MANY:
             $classMetadata->mapManyEmbedded($newMapping);
             break;
     }
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:27,代码来源:ResolveTargetDocumentListener.php


示例16: buildMetadata

 protected function buildMetadata(ClassMetadata $source, ClassMetadata $target, $eventManager)
 {
     $sourceReflClass = $source->getReflectionClass();
     $targetReflClass = $target->getReflectionClass();
     //Document annotations
     foreach ($this->annotationReader->getClassAnnotations($sourceReflClass) as $annotation) {
         if (defined(get_class($annotation) . '::event')) {
             // Raise annotation event
             if ($eventManager->hasListeners($annotation::event)) {
                 $eventManager->dispatchEvent($annotation::event, new AnnotationEventArgs($target, EventType::document, $annotation, $targetReflClass, $eventManager));
             }
         }
     }
     //Field annotations
     foreach ($sourceReflClass->getProperties() as $reflField) {
         foreach ($this->annotationReader->getPropertyAnnotations($reflField) as $annotation) {
             if (defined(get_class($annotation) . '::event')) {
                 // Raise annotation event
                 if ($eventManager->hasListeners($annotation::event)) {
                     $eventManager->dispatchEvent($annotation::event, new AnnotationEventArgs($target, EventType::field, $annotation, $reflField, $eventManager));
                 }
             }
         }
     }
     //Method annotations
     foreach ($sourceReflClass->getMethods() as $reflMethod) {
         foreach ($this->annotationReader->getMethodAnnotations($reflMethod) as $annotation) {
             if (defined(get_class($annotation) . '::event')) {
                 // Raise annotation event
                 if ($eventManager->hasListeners($annotation::event)) {
                     $eventManager->dispatchEvent($annotation::event, new AnnotationEventArgs($target, EventType::method, $annotation, $reflMethod, $eventManager));
                 }
             }
         }
     }
 }
开发者ID:superdweebie,项目名称:doctrine-extensions,代码行数:36,代码来源:MainSubscriber.php


示例17: prepareWhereValue

    /**
     * Prepare where values converting document object field names to the document collection
     * field name.
     *
     * @param string $fieldName
     * @param string $value
     * @return string $value
     */
    private function prepareWhereValue(&$fieldName, $value)
    {
        if (strpos($fieldName, '.') !== false) {
            $e = explode('.', $fieldName);

            $mapping = $this->class->getFieldMapping($e[0]);

            if ($this->class->hasField($e[0])) {
                $name = $this->class->fieldMappings[$e[0]]['name'];
                if ($name !== $e[0]) {
                    $e[0] = $name;
                }
            }

            if (isset($mapping['targetDocument'])) {
                $targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
                if ($targetClass->hasField($e[1]) && $targetClass->identifier === $e[1]) {
                    $fieldName = $e[0] . '.$id';
                    $value = $targetClass->getDatabaseIdentifierValue($value);
                } elseif ($e[1] === '$id') {
                    $value = $targetClass->getDatabaseIdentifierValue($value);
                }
            }
        } elseif ($this->class->hasField($fieldName) && ! $this->class->isIdentifier($fieldName)) {
            $name = $this->class->fieldMappings[$fieldName]['name'];
            if ($name !== $fieldName) {
                $fieldName = $name;
            }
        } else {
            if ($fieldName === $this->class->identifier || $fieldName === '_id') {
                $fieldName = '_id';
                if (is_array($value)) {
                    if (isset($value[$this->cmd.'in'])) {
                        foreach ($value[$this->cmd.'in'] as $k => $v) {
                            $value[$this->cmd.'in'][$k] = $this->class->getDatabaseIdentifierValue($v);
                        }
                    } else {
                        foreach ($value as $k => $v) {
                            $value[$k] = $this->class->getDatabaseIdentifierValue($v);
                        }
                    }
                } else {
                    $value = $this->class->getDatabaseIdentifierValue($value);
                }
            }
        }
        return $value;
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:56,代码来源:DocumentPersister.php


示例18: includesReferenceTo

 /**
  * Checks that the current field includes a reference to the supplied document.
  */
 public function includesReferenceTo($document)
 {
     if ($this->currentField) {
         $this->query[$this->currentField][$this->cmd . 'elemMatch'] = $this->class ? $this->dm->createDBRef($document, $this->class->getFieldMapping($this->currentField)) : $this->dm->createDBRef($document);
     } else {
         $this->query[$this->cmd . 'elemMatch'] = $this->dm->createDBRef($document);
     }
     return $this;
 }
开发者ID:JasonOcean,项目名称:iOS_Interest_Group,代码行数:12,代码来源:Expr.php


示例19: getId

 /** {@inheritdoc} */
 public function getId($object)
 {
     if (!is_a($object, $this->getClass())) {
         throw new MetadataException("Object isn't subclass of '{$this->getClass()}', given '" . (is_object($object) ? get_class($object) : gettype($object)) . "'.");
     }
     if ($this->classMetadata->isEmbeddedDocument) {
         throw new MetadataException("Embedded document '{$this->getClass()}' hasn't ID.");
     }
     $identifier = $this->classMetadata->getIdentifierValue($object);
     return empty($identifier) ? NULL : $identifier;
 }
开发者ID:mike227,项目名称:n-forms,代码行数:12,代码来源:ClassMetadata.php


示例20: getFieldsMetadata

 public function getFieldsMetadata($class)
 {
     $result = array();
     foreach ($this->odmMetadata->getReflectionProperties() as $property) {
         $name = $property->getName();
         $mapping = $this->odmMetadata->getFieldMapping($name);
         $values = array('title' => $name, 'source' => true);
         if (isset($mapping['fieldName'])) {
             $values['field'] = $mapping['fieldName'];
         }
         if (isset($mapping['id']) && $mapping['id'] == 'id') {
             $values['primary'] = true;
         }
         switch ($mapping['type']) {
             case 'id':
             case 'int':
             case 'string':
             case 'float':
             case 'many':
                 $values['type'] = 'text';
                 break;
             case 'boolean':
                 $values['type'] = 'boolean';
                 break;
             case 'date':
                 $values['type'] = 'date';
                 break;
         }
         $result[$name] = $values;
     }
     return $result;
 }
开发者ID:sxn,项目名称:DataGridBundle,代码行数:32,代码来源:Document.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Mapping\ClassMetadataInfo类代码示例发布时间:2022-05-23
下一篇:
PHP Event\LifecycleEventArgs类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap