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


PHP MongoDBException::identifierRequired方法代码示例

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


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

示例1: validateIdentifier

 /**
  * Validates the identifier mapping.
  *
  * @param ClassMetadata $class
  */
 protected function validateIdentifier($class)
 {
     if (!$class->identifier && !$class->isMappedSuperclass && !$class->isEmbeddedDocument) {
         throw MongoDBException::identifierRequired($class->name);
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:11,代码来源:ClassMetadataFactory.php

示例2: loadMetadata

 /**
  * Loads the metadata of the class in question and all it's ancestors whose metadata
  * is still not loaded.
  *
  * @param string $name The name of the class for which the metadata should get loaded.
  * @param array  $tables The metadata collection to which the loaded metadata is added.
  */
 private function loadMetadata($className)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     $loaded = array();
     $parentClasses = $this->getParentClasses($className);
     $parentClasses[] = $className;
     // Move down the hierarchy of parent classes, starting from the topmost class
     $parent = null;
     $visited = array();
     foreach ($parentClasses as $className) {
         if (isset($this->loadedMetadata[$className])) {
             $parent = $this->loadedMetadata[$className];
             if (!$parent->isMappedSuperclass && !$parent->isEmbeddedDocument) {
                 array_unshift($visited, $className);
             }
             continue;
         }
         $class = $this->newClassMetadataInstance($className);
         if ($parent) {
             if (!$parent->isMappedSuperclass) {
                 $class->setInheritanceType($parent->inheritanceType);
                 $class->setDiscriminatorField($parent->discriminatorField);
                 $class->setDiscriminatorMap($parent->discriminatorMap);
             }
             $class->setIdGeneratorType($parent->generatorType);
             $this->addInheritedFields($class, $parent);
             $this->addInheritedIndexes($class, $parent);
             $class->setIdentifier($parent->identifier);
             $class->setVersioned($parent->isVersioned);
             $class->setVersionField($parent->versionField);
             $class->setLifecycleCallbacks($parent->lifecycleCallbacks);
             $class->setChangeTrackingPolicy($parent->changeTrackingPolicy);
             $class->setFile($parent->getFile());
         }
         // Invoke driver
         try {
             $this->driver->loadMetadataForClass($className, $class);
         } catch (ReflectionException $e) {
             throw MongoDBException::reflectionFailure($className, $e);
         }
         if (!$class->identifier && !$class->isMappedSuperclass && !$class->isEmbeddedDocument) {
             throw MongoDBException::identifierRequired($className);
         }
         if ($parent && !$parent->isMappedSuperclass && !$class->isEmbeddedDocument) {
             if ($parent->generatorType) {
                 $class->setIdGeneratorType($parent->generatorType);
             }
             if ($parent->generatorOptions) {
                 $class->setIdGeneratorOptions($parent->generatorOptions);
             }
             if ($parent->idGenerator) {
                 $class->setIdGenerator($parent->idGenerator);
             }
         } else {
             $this->completeIdGeneratorMapping($class);
         }
         if ($parent && $parent->isInheritanceTypeSingleCollection()) {
             $class->setDatabase($parent->getDatabase());
             $class->setCollection($parent->getCollection());
         }
         $db = $class->getDatabase() ?: $this->config->getDefaultDB();
         $class->setDatabase($this->dm->formatDBName($db));
         $class->setParentClasses($visited);
         if ($this->evm->hasListeners(Events::loadClassMetadata)) {
             $eventArgs = new \Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs($class, $this->dm);
             $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
         }
         $this->loadedMetadata[$className] = $class;
         $parent = $class;
         if (!$class->isMappedSuperclass && !$class->isEmbeddedDocument) {
             array_unshift($visited, $className);
         }
         $loaded[] = $className;
     }
     return $loaded;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:85,代码来源:ClassMetadataFactory.php


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