當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。