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


PHP MappingException::classIsNotAValidEntityOrMapperSuperClass方法代码示例

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


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

示例1: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $xmlRoot = $this->getElement($className);
     if ($xmlRoot->getName() == 'entity') {
         $metadata->setCustomRepositoryClass(isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null);
     } else {
         if ($xmlRoot->getName() == 'mapped-superclass') {
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMapperSuperClass($className);
         }
     }
     // Evaluate <entity...> attributes
     if (isset($xmlRoot['table'])) {
         $metadata->primaryTable['name'] = (string) $xmlRoot['table'];
     }
     if (isset($xmlRoot['schema'])) {
         $metadata->primaryTable['schema'] = (string) $xmlRoot['schema'];
     }
     if (isset($xmlRoot['inheritance-type'])) {
         $inheritanceType = (string) $xmlRoot['inheritance-type'];
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
     }
     // Evaluate <discriminator-column...>
     if (isset($xmlRoot->{'discriminator-column'})) {
         $discrColumn = $xmlRoot->{'discriminator-column'};
         $metadata->setDiscriminatorColumn(array('name' => (string) $discrColumn['name'], 'type' => (string) $discrColumn['type'], 'length' => (string) $discrColumn['length']));
     }
     // Evaluate <discriminator-map...>
     if (isset($xmlRoot->{'discriminator-map'})) {
         $map = array();
         foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) {
             $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class'];
         }
         $metadata->setDiscriminatorMap($map);
     }
     // Evaluate <change-tracking-policy...>
     if (isset($xmlRoot->{'change-tracking-policy'})) {
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . strtoupper((string) $xmlRoot->{'change-tracking-policy'})));
     }
     // Evaluate <indexes...>
     if (isset($xmlRoot->indexes)) {
         foreach ($xmlRoot->indexes->index as $index) {
             if (is_string($index['columns'])) {
                 $columns = explode(',', $index['columns']);
             } else {
                 $columns = $index['columns'];
             }
             $metadata->primaryTable['indexes'][$index['name']] = array('columns' => $columns);
         }
     }
     // Evaluate <unique-constraints..>
     if (isset($xmlRoot->{'unique-constraints'})) {
         foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $unique) {
             if (is_string($unique['columns'])) {
                 $columns = explode(',', $unique['columns']);
             } else {
                 $columns = $unique['columns'];
             }
             $metadata->primaryTable['uniqueConstraints'][$unique['name']] = array('columns' => $columns);
         }
     }
     // Evaluate <field ...> mappings
     if (isset($xmlRoot->field)) {
         foreach ($xmlRoot->field as $fieldMapping) {
             $mapping = array('fieldName' => (string) $fieldMapping['name'], 'type' => (string) $fieldMapping['type']);
             if (isset($fieldMapping['column'])) {
                 $mapping['columnName'] = (string) $fieldMapping['column'];
             }
             if (isset($fieldMapping['length'])) {
                 $mapping['length'] = (int) $fieldMapping['length'];
             }
             if (isset($fieldMapping['precision'])) {
                 $mapping['precision'] = (int) $fieldMapping['precision'];
             }
             if (isset($fieldMapping['scale'])) {
                 $mapping['scale'] = (int) $fieldMapping['scale'];
             }
             if (isset($fieldMapping['unique'])) {
                 $mapping['unique'] = (string) $fieldMapping['unique'] == "false" ? false : true;
             }
             if (isset($fieldMapping['options'])) {
                 $mapping['options'] = (array) $fieldMapping['options'];
             }
             if (isset($fieldMapping['nullable'])) {
                 $mapping['nullable'] = (string) $fieldMapping['nullable'] == "false" ? false : true;
             }
             if (isset($fieldMapping['version']) && $fieldMapping['version']) {
                 $metadata->setVersionMapping($mapping);
             }
             if (isset($fieldMapping['column-definition'])) {
                 $mapping['columnDefinition'] = (string) $fieldMapping['column-definition'];
             }
             $metadata->mapField($mapping);
         }
     }
     // Evaluate <id ...> mappings
//.........这里部分代码省略.........
开发者ID:andreia,项目名称:doctrine,代码行数:101,代码来源:XmlDriver.php

示例2: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $element = $this->getElement($className);
     if ($element['type'] == 'entity') {
         $metadata->setCustomRepositoryClass(isset($element['repositoryClass']) ? $element['repositoryClass'] : null);
     } else {
         if ($element['type'] == 'mappedSuperclass') {
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMapperSuperClass($className);
         }
     }
     // Evaluate root level properties
     if (isset($element['table'])) {
         $metadata->primaryTable['name'] = $element['table'];
     }
     if (isset($element['schema'])) {
         $metadata->primaryTable['schema'] = $element['schema'];
     }
     if (isset($element['inheritanceType'])) {
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
     }
     // Evaluate discriminatorColumn
     if (isset($element['discriminatorColumn'])) {
         $discrColumn = $element['discriminatorColumn'];
         $metadata->setDiscriminatorColumn(array('name' => $discrColumn['name'], 'type' => $discrColumn['type'], 'length' => $discrColumn['length']));
     }
     // Evaluate discriminatorMap
     if (isset($element['discriminatorMap'])) {
         $metadata->setDiscriminatorMap($element['discriminatorMap']);
     }
     // Evaluate changeTrackingPolicy
     if (isset($element['changeTrackingPolicy'])) {
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . strtoupper($element['changeTrackingPolicy'])));
     }
     // Evaluate indexes
     if (isset($element['indexes'])) {
         foreach ($element['indexes'] as $name => $index) {
             if (!isset($index['name'])) {
                 $index['name'] = $name;
             }
             if (is_string($index['columns'])) {
                 $columns = explode(',', $index['columns']);
             } else {
                 $columns = $index['columns'];
             }
             $metadata->primaryTable['indexes'][$index['name']] = array('columns' => $columns);
         }
     }
     // Evaluate uniqueConstraints
     if (isset($element['uniqueConstraints'])) {
         foreach ($element['uniqueConstraints'] as $name => $unique) {
             if (!isset($unique['name'])) {
                 $unique['name'] = $name;
             }
             if (is_string($unique['columns'])) {
                 $columns = explode(',', $unique['columns']);
             } else {
                 $columns = $unique['columns'];
             }
             $metadata->primaryTable['uniqueConstraints'][$unique['name']] = array('columns' => $columns);
         }
     }
     if (isset($element['id'])) {
         // Evaluate identifier settings
         foreach ($element['id'] as $name => $idElement) {
             $mapping = array('id' => true, 'fieldName' => $name, 'type' => $idElement['type']);
             if (isset($idElement['column'])) {
                 $mapping['columnName'] = $idElement['column'];
             }
             $metadata->mapField($mapping);
             if (isset($idElement['generator'])) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . strtoupper($idElement['generator']['strategy'])));
             }
         }
     }
     // Evaluate fields
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $name => $fieldMapping) {
             if (!isset($fieldMapping['type'])) {
                 throw MappingException::propertyTypeIsRequired($className, $name);
             }
             $e = explode('(', $fieldMapping['type']);
             $fieldMapping['type'] = $e[0];
             if (isset($e[1])) {
                 $fieldMapping['length'] = substr($e[1], 0, strlen($e[1]) - 1);
             }
             $mapping = array('fieldName' => $name, 'type' => $fieldMapping['type']);
             if (isset($fieldMapping['id'])) {
                 $mapping['id'] = true;
                 if (isset($fieldMapping['generator']['strategy'])) {
                     $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . strtoupper($fieldMapping['generator']['strategy'])));
                 }
             }
             // Check for SequenceGenerator/TableGenerator definition
             if (isset($fieldMapping['sequenceGenerator'])) {
                 $metadata->setSequenceGeneratorDefinition($fieldMapping['sequenceGenerator']);
//.........这里部分代码省略.........
开发者ID:andreia,项目名称:doctrine,代码行数:101,代码来源:YamlDriver.php


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