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


PHP ClassMetadataInfo::setRequireIndexes方法代码示例

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


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

示例1: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $class)
 {
     $element = $this->getElement($className);
     if (!$element) {
         return;
     }
     $element['type'] = isset($element['type']) ? $element['type'] : 'document';
     if (isset($element['db'])) {
         $class->setDatabase($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'], isset($index['options']) ? $index['options'] : array());
         }
     }
     if (isset($element['inheritanceType'])) {
         $class->setInheritanceType(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
     }
     if (isset($element['discriminatorField'])) {
         $class->setDiscriminatorField(array_intersect_key($element['discriminatorField'], array('fieldName' => 1, 'name' => 1)));
     }
     if (isset($element['discriminatorMap'])) {
         $class->setDiscriminatorMap($element['discriminatorMap']);
     }
     if (isset($element['changeTrackingPolicy'])) {
         $class->setChangeTrackingPolicy(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::CHANGETRACKING_' . strtoupper($element['changeTrackingPolicy'])));
     }
     if (isset($element['requireIndexes'])) {
         $class->setRequireIndexes($element['requireIndexes']);
     }
     if (isset($element['slaveOkay'])) {
         $class->setSlaveOkay($element['slaveOkay']);
     }
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $fieldName => $mapping) {
             if (is_string($mapping)) {
                 $type = $mapping;
                 $mapping = array();
                 $mapping['type'] = $type;
             }
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             if (isset($mapping['type']) && $mapping['type'] === 'collection') {
                 $mapping['strategy'] = isset($mapping['strategy']) ? $mapping['strategy'] : 'pushAll';
             }
             $this->addFieldMapping($class, $mapping);
         }
     }
     if (isset($element['embedOne'])) {
         foreach ($element['embedOne'] as $fieldName => $embed) {
             $this->addMappingFromEmbed($class, $fieldName, $embed, 'one');
         }
     }
     if (isset($element['embedMany'])) {
         foreach ($element['embedMany'] as $fieldName => $embed) {
             $this->addMappingFromEmbed($class, $fieldName, $embed, 'many');
         }
     }
     if (isset($element['referenceOne'])) {
         foreach ($element['referenceOne'] as $fieldName => $reference) {
             $this->addMappingFromReference($class, $fieldName, $reference, 'one');
         }
     }
     if (isset($element['referenceMany'])) {
         foreach ($element['referenceMany'] as $fieldName => $reference) {
             $this->addMappingFromReference($class, $fieldName, $reference, 'many');
         }
     }
     if (isset($element['lifecycleCallbacks'])) {
         foreach ($element['lifecycleCallbacks'] as $type => $methods) {
             foreach ($methods as $method) {
                 $class->addLifecycleCallback($method, constant('Doctrine\\ODM\\MongoDB\\Events::' . $type));
             }
         }
     }
 }
开发者ID:romainneutron,项目名称:mongodb-odm,代码行数:92,代码来源:YamlDriver.php


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