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


PHP MongoDBException::duplicateFieldMapping方法代码示例

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


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

示例1: mapField

 /**
  * Map a field.
  *
  * @param array $mapping The mapping information.
  */
 public function mapField(array $mapping)
 {
     if (isset($mapping['name'])) {
         $mapping['fieldName'] = $mapping['name'];
     }
     if (!isset($mapping['fieldName'])) {
         throw MongoDBException::missingFieldName($this->name);
     }
     if (isset($this->fieldMappings[$mapping['fieldName']])) {
         throw MongoDBException::duplicateFieldMapping($this->name, $mapping['fieldName']);
     }
     if ($this->discriminatorField['name'] === $mapping['fieldName']) {
         throw MongoDBException::duplicateFieldMapping($this->name, $mapping['fieldName']);
     }
     if (isset($mapping['targetDocument']) && strpos($mapping['targetDocument'], '\\') === false && strlen($this->namespace)) {
         $mapping['targetDocument'] = $this->namespace . '\\' . $mapping['targetDocument'];
     }
     if (isset($mapping['discriminatorMap'])) {
         foreach ($mapping['discriminatorMap'] as $key => $class) {
             if (strpos($class, '\\') === false && strlen($this->namespace)) {
                 $mapping['discriminatorMap'][$key] = $this->namespace . '\\' . $class;
             }
         }
     }
     if ($this->reflClass->hasProperty($mapping['fieldName'])) {
         $reflProp = $this->reflClass->getProperty($mapping['fieldName']);
         $reflProp->setAccessible(true);
         $this->reflFields[$mapping['fieldName']] = $reflProp;
     }
     if (isset($mapping['cascade']) && is_string($mapping['cascade'])) {
         $mapping['cascade'] = array($mapping['cascade']);
     }
     if (isset($mapping['cascade']) && in_array('all', (array) $mapping['cascade'])) {
         unset($mapping['cascade']);
         $default = true;
     } else {
         $default = false;
     }
     $mapping['isCascadeRemove'] = $default;
     $mapping['isCascadePersist'] = $default;
     $mapping['isCascadeRefresh'] = $default;
     $mapping['isCascadeMerge'] = $default;
     $mapping['isCascadeDetach'] = $default;
     if (isset($mapping['cascade']) && is_array($mapping['cascade'])) {
         foreach ($mapping['cascade'] as $cascade) {
             $mapping['isCascade' . ucfirst($cascade)] = true;
         }
     }
     unset($mapping['cascade']);
     if (isset($mapping['file']) && $mapping['file'] === true) {
         $this->file = $mapping['fieldName'];
     }
     if (isset($mapping['id']) && $mapping['id'] === true) {
         $mapping['type'] = isset($mapping['type']) ? $mapping['type'] : 'id';
         $this->identifier = $mapping['fieldName'];
     }
     if (!isset($mapping['nullable'])) {
         $mapping['nullable'] = false;
     }
     $this->fieldMappings[$mapping['fieldName']] = $mapping;
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:66,代码来源:ClassMetadata.php

示例2: mapField

    /**
     * Map a field.
     *
     * @param array $mapping The mapping information.
     */
    public function mapField(array $mapping)
    {
        if ( ! isset($mapping['fieldName']) && isset($mapping['name'])) {
            $mapping['fieldName'] = $mapping['name'];
        }
        if ( ! isset($mapping['fieldName'])) {
            throw MongoDBException::missingFieldName($this->name);
        }
        if ( ! isset($mapping['name'])) {
            $mapping['name'] = $mapping['fieldName'];
        }
        if (isset($this->fieldMappings[$mapping['fieldName']])) {
            throw MongoDBException::duplicateFieldMapping($this->name, $mapping['fieldName']);
        }
        if ($this->discriminatorField['name'] === $mapping['fieldName']) {
            throw MongoDBException::duplicateFieldMapping($this->name, $mapping['fieldName']);
        }
        if (isset($mapping['targetDocument']) && strpos($mapping['targetDocument'], '\\') === false && strlen($this->namespace)) {
            $mapping['targetDocument'] = $this->namespace . '\\' . $mapping['targetDocument'];
        }

        if (isset($mapping['discriminatorMap'])) {
            foreach ($mapping['discriminatorMap'] as $key => $class) {
                if (strpos($class, '\\') === false && strlen($this->namespace)) {
                    $mapping['discriminatorMap'][$key] = $this->namespace . '\\' . $class;
                }
            }
        }

        if (isset($mapping['cascade']) && is_string($mapping['cascade'])) {
            $mapping['cascade'] = array($mapping['cascade']);
        }
        if (isset($mapping['cascade']) && in_array('all', (array) $mapping['cascade'])) {
            unset($mapping['cascade']);
            $default = true;
        } else {
            $default = false;
        }
        $mapping['isCascadeRemove'] = $default;
        $mapping['isCascadePersist'] = $default;
        $mapping['isCascadeRefresh'] = $default;
        $mapping['isCascadeMerge'] = $default;
        $mapping['isCascadeDetach'] = $default;
        $mapping['isCascadeCallbacks'] = $default;
        if (isset($mapping['cascade']) && is_array($mapping['cascade'])) {
            foreach ($mapping['cascade'] as $cascade) {
                $mapping['isCascade' . ucfirst($cascade)] = true;
            }
        }
        unset($mapping['cascade']);
        if (isset($mapping['file']) && $mapping['file'] === true) {
            $this->file = $mapping['fieldName'];
            $mapping['name'] = 'file';
        }
        if (isset($mapping['distance']) && $mapping['distance'] === true) {
            $this->distance = $mapping['fieldName'];
        }
        if (isset($mapping['id']) && $mapping['id'] === true) {
            $mapping['name'] = '_id';
            $mapping['type'] = isset($mapping['type']) ? $mapping['type'] : 'id';
            $this->identifier = $mapping['fieldName'];
            if (isset($mapping['strategy'])) {
                $generatorType = constant('Doctrine\ODM\MongoDB\Mapping\ClassMetadata::GENERATOR_TYPE_' . strtoupper($mapping['strategy']));
                if ($generatorType !== self::GENERATOR_TYPE_AUTO) {
                    $mapping['type'] = 'custom_id';
                }
                $this->generatorType = $generatorType;
                $this->generatorOptions = isset($mapping['options']) ? $mapping['options'] : array();
            }
        }
        if ( ! isset($mapping['nullable'])) {
            $mapping['nullable'] = false;
        }
        if (isset($mapping['reference']) && $mapping['type'] === 'one') {
            $mapping['association'] = self::REFERENCE_ONE;
        }
        if (isset($mapping['reference']) && $mapping['type'] === 'many') {
            $mapping['association'] = self::REFERENCE_MANY;
        }
        if (isset($mapping['embedded']) && $mapping['type'] === 'one') {
            $mapping['association'] = self::EMBED_ONE;
        }
        if (isset($mapping['embedded']) && $mapping['type'] === 'many') {
            $mapping['association'] = self::EMBED_MANY;
        }
        /*
        if (isset($mapping['type']) && ($mapping['type'] === 'one' || $mapping['type'] === 'many')) {
            $mapping['type'] = $mapping['type'] === 'one' ? self::ONE : self::MANY;
        }
        */
        if (isset($mapping['version'])) {
            $this->setVersionMapping($mapping);
        }
        if (isset($mapping['lock'])) {
            $this->setLockMapping($mapping);
//.........这里部分代码省略.........
开发者ID:nresni,项目名称:symfony-sandbox,代码行数:101,代码来源:ClassMetadataInfo.php


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