當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassMetadata::setDiscriminatorColumn方法代碼示例

本文整理匯總了PHP中Doctrine\ODM\MongoDB\Mapping\ClassMetadata::setDiscriminatorColumn方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadata::setDiscriminatorColumn方法的具體用法?PHP ClassMetadata::setDiscriminatorColumn怎麽用?PHP ClassMetadata::setDiscriminatorColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ODM\MongoDB\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::setDiscriminatorColumn方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     $element = $this->getElement($className);
     if (!$element) {
         return;
     }
     $element['type'] = isset($element['type']) ? $element['type'] : 'document';
     if (isset($element['db'])) {
         $class->setDB($element['db']);
     }
     if (isset($element['collection'])) {
         $class->setCollection($element['collection']);
     }
     if ($element['type'] == 'document') {
         if (isset($element['repositoryClass'])) {
             $class->setCustomRepositoryClass($element['repositoryClass']);
         }
     } elseif ($element['type'] === 'mappedSuperclass') {
         $class->isMappedSuperclass = true;
     } elseif ($element['type'] === 'embeddedDocument') {
         $class->isEmbeddedDocument = true;
     }
     if (isset($element['indexes'])) {
         foreach ($element['indexes'] as $index) {
             $class->addIndex($index['keys'], $index['options']);
         }
     }
     if (isset($element['inheritanceType'])) {
         $class->setInheritanceType(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
     }
     if (isset($element['discriminatorColumn'])) {
         $discrColumn = $element['discriminatorColumn'];
         $class->setDiscriminatorColumn(array('name' => $discrColumn['name'], 'fieldName' => $discrColumn['fieldName']));
     }
     if (isset($element['discriminatorMap'])) {
         $class->setDiscriminatorMap($element['discriminatorMap']);
     }
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $fieldName => $mapping) {
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             $class->mapField($mapping);
         }
     }
     if (isset($element['embedOne'])) {
         foreach ($element['embedOne'] as $fieldName => $embed) {
             $mapping = $this->_getMappingFromEmbed($fieldName, $embed, 'one');
             $class->mapField($mapping);
         }
     }
     if (isset($element['embedMany'])) {
         foreach ($element['embedMany'] as $fieldName => $embed) {
             $mapping = $this->_getMappingFromEmbed($fieldName, $embed, 'many');
             $class->mapField($mapping);
         }
     }
     if (isset($element['referenceOne'])) {
         foreach ($element['referenceOne'] as $fieldName => $reference) {
             $mapping = $this->_getMappingFromReference($fieldName, $reference, 'one');
             $class->mapField($mapping);
         }
     }
     if (isset($element['referenceMany'])) {
         foreach ($element['referenceMany'] as $fieldName => $reference) {
             $mapping = $this->_getMappingFromReference($fieldName, $reference, 'many');
             $class->mapField($mapping);
         }
     }
     if (isset($element['lifecycleCallbacks'])) {
         foreach ($element['lifecycleCallbacks'] as $type => $methods) {
             foreach ($methods as $method) {
                 $class->addLifecycleCallback($method, constant('Doctrine\\ORM\\Events::' . $type));
             }
         }
     }
 }
開發者ID:poulikov,項目名稱:mongodb-odm,代碼行數:80,代碼來源:YamlDriver.php


注:本文中的Doctrine\ODM\MongoDB\Mapping\ClassMetadata::setDiscriminatorColumn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。