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


PHP MappingException::tableIdGeneratorNotImplemented方法代码示例

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


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

示例1: loadMetadataForClass


//.........这里部分代码省略.........
                 $mapping['options'] = $this->_parseOptions($fieldMapping->options->children());
             }
             $metadata->mapField($mapping);
         }
     }
     // Evaluate <id ...> mappings
     $associationIds = array();
     foreach ($xmlRoot->id as $idElement) {
         if ((bool) $idElement['association-key'] == true) {
             $associationIds[(string) $idElement['name']] = true;
             continue;
         }
         $mapping = array('id' => true, 'fieldName' => (string) $idElement['name']);
         if (isset($idElement['type'])) {
             $mapping['type'] = (string) $idElement['type'];
         }
         if (isset($idElement['column'])) {
             $mapping['columnName'] = (string) $idElement['column'];
         }
         if (isset($idElement['column-definition'])) {
             $mapping['columnDefinition'] = (string) $idElement['column-definition'];
         }
         $metadata->mapField($mapping);
         if (isset($idElement->generator)) {
             $strategy = isset($idElement->generator['strategy']) ? (string) $idElement->generator['strategy'] : 'AUTO';
             $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $strategy));
         }
         // Check for SequenceGenerator/TableGenerator definition
         if (isset($idElement->{'sequence-generator'})) {
             $seqGenerator = $idElement->{'sequence-generator'};
             $metadata->setSequenceGeneratorDefinition(array('sequenceName' => (string) $seqGenerator['sequence-name'], 'allocationSize' => (string) $seqGenerator['allocation-size'], 'initialValue' => (string) $seqGenerator['initial-value']));
         } else {
             if (isset($idElement->{'table-generator'})) {
                 throw MappingException::tableIdGeneratorNotImplemented($className);
             }
         }
     }
     // Evaluate <one-to-one ...> mappings
     if (isset($xmlRoot->{'one-to-one'})) {
         foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) {
             $mapping = array('fieldName' => (string) $oneToOneElement['field'], 'targetEntity' => (string) $oneToOneElement['target-entity']);
             if (isset($associationIds[$mapping['fieldName']])) {
                 $mapping['id'] = true;
             }
             if (isset($oneToOneElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . (string) $oneToOneElement['fetch']);
             }
             if (isset($oneToOneElement['mapped-by'])) {
                 $mapping['mappedBy'] = (string) $oneToOneElement['mapped-by'];
             } else {
                 if (isset($oneToOneElement['inversed-by'])) {
                     $mapping['inversedBy'] = (string) $oneToOneElement['inversed-by'];
                 }
                 $joinColumns = array();
                 if (isset($oneToOneElement->{'join-column'})) {
                     $joinColumns[] = $this->_getJoinColumnMapping($oneToOneElement->{'join-column'});
                 } else {
                     if (isset($oneToOneElement->{'join-columns'})) {
                         foreach ($oneToOneElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
                             $joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement);
                         }
                     }
                 }
                 $mapping['joinColumns'] = $joinColumns;
             }
             if (isset($oneToOneElement->cascade)) {
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:67,代码来源:XmlDriver.php

示例2: loadMetadataForClass


//.........这里部分代码省略.........
             if ($columnAnnot->type == null) {
                 throw MappingException::propertyTypeIsRequired($className, $property->getName());
             }
             $mapping['type'] = $columnAnnot->type;
             $mapping['length'] = $columnAnnot->length;
             $mapping['precision'] = $columnAnnot->precision;
             $mapping['scale'] = $columnAnnot->scale;
             $mapping['nullable'] = $columnAnnot->nullable;
             $mapping['unique'] = $columnAnnot->unique;
             if ($columnAnnot->options) {
                 $mapping['options'] = $columnAnnot->options;
             }
             if (isset($columnAnnot->name)) {
                 $mapping['columnName'] = $columnAnnot->name;
             }
             if (isset($columnAnnot->columnDefinition)) {
                 $mapping['columnDefinition'] = $columnAnnot->columnDefinition;
             }
             if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\GeneratedValue')) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
             }
             if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Version')) {
                 $metadata->setVersionMapping($mapping);
             }
             $metadata->mapField($mapping);
             // Check for SequenceGenerator/TableGenerator definition
             if ($seqGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\SequenceGenerator')) {
                 $metadata->setSequenceGeneratorDefinition(array('sequenceName' => $seqGeneratorAnnot->sequenceName, 'allocationSize' => $seqGeneratorAnnot->allocationSize, 'initialValue' => $seqGeneratorAnnot->initialValue));
             } else {
                 if ($tblGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\TableGenerator')) {
                     throw MappingException::tableIdGeneratorNotImplemented($className);
                 }
             }
         } else {
             if ($oneToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToOne')) {
                 if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                     $mapping['id'] = true;
                 }
                 $mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
                 $mapping['joinColumns'] = $joinColumns;
                 $mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
                 $mapping['inversedBy'] = $oneToOneAnnot->inversedBy;
                 $mapping['cascade'] = $oneToOneAnnot->cascade;
                 $mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval;
                 $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAnnot->fetch);
                 $metadata->mapOneToOne($mapping);
             } else {
                 if ($oneToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToMany')) {
                     $mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
                     $mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
                     $mapping['cascade'] = $oneToManyAnnot->cascade;
                     $mapping['indexBy'] = $oneToManyAnnot->indexBy;
                     $mapping['orphanRemoval'] = $oneToManyAnnot->orphanRemoval;
                     $mapping['fetch'] = $this->getFetchMode($className, $oneToManyAnnot->fetch);
                     if ($orderByAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
                         $mapping['orderBy'] = $orderByAnnot->value;
                     }
                     $metadata->mapOneToMany($mapping);
                 } else {
                     if ($manyToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToOne')) {
                         if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                             $mapping['id'] = true;
                         }
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:67,代码来源:AnnotationDriver.php

示例3: loadMetadataForClass


//.........这里部分代码省略.........
     foreach ($xmlRoot->id as $idElement) {
         if (isset($idElement['association-key']) && $this->evaluateBoolean($idElement['association-key'])) {
             $associationIds[(string) $idElement['name']] = true;
             continue;
         }
         $mapping = array('id' => true, 'fieldName' => (string) $idElement['name']);
         if (isset($idElement['type'])) {
             $mapping['type'] = (string) $idElement['type'];
         }
         if (isset($idElement['length'])) {
             $mapping['length'] = (string) $idElement['length'];
         }
         if (isset($idElement['column'])) {
             $mapping['columnName'] = (string) $idElement['column'];
         }
         if (isset($idElement['column-definition'])) {
             $mapping['columnDefinition'] = (string) $idElement['column-definition'];
         }
         $metadata->mapField($mapping);
         if (isset($idElement->generator)) {
             $strategy = isset($idElement->generator['strategy']) ? (string) $idElement->generator['strategy'] : 'AUTO';
             $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $strategy));
         }
         // Check for SequenceGenerator/TableGenerator definition
         if (isset($idElement->{'sequence-generator'})) {
             $seqGenerator = $idElement->{'sequence-generator'};
             $metadata->setSequenceGeneratorDefinition(array('sequenceName' => (string) $seqGenerator['sequence-name'], 'allocationSize' => (string) $seqGenerator['allocation-size'], 'initialValue' => (string) $seqGenerator['initial-value']));
         } else {
             if (isset($idElement->{'custom-id-generator'})) {
                 $customGenerator = $idElement->{'custom-id-generator'};
                 $metadata->setCustomGeneratorDefinition(array('class' => (string) $customGenerator['class']));
             } else {
                 if (isset($idElement->{'table-generator'})) {
                     throw MappingException::tableIdGeneratorNotImplemented($className);
                 }
             }
         }
     }
     // Evaluate <one-to-one ...> mappings
     if (isset($xmlRoot->{'one-to-one'})) {
         foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) {
             $mapping = array('fieldName' => (string) $oneToOneElement['field'], 'targetEntity' => (string) $oneToOneElement['target-entity']);
             if (isset($associationIds[$mapping['fieldName']])) {
                 $mapping['id'] = true;
             }
             if (isset($oneToOneElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . (string) $oneToOneElement['fetch']);
             }
             if (isset($oneToOneElement['mapped-by'])) {
                 $mapping['mappedBy'] = (string) $oneToOneElement['mapped-by'];
             } else {
                 if (isset($oneToOneElement['inversed-by'])) {
                     $mapping['inversedBy'] = (string) $oneToOneElement['inversed-by'];
                 }
                 $joinColumns = array();
                 if (isset($oneToOneElement->{'join-column'})) {
                     $joinColumns[] = $this->joinColumnToArray($oneToOneElement->{'join-column'});
                 } else {
                     if (isset($oneToOneElement->{'join-columns'})) {
                         foreach ($oneToOneElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
                             $joinColumns[] = $this->joinColumnToArray($joinColumnElement);
                         }
                     }
                 }
                 $mapping['joinColumns'] = $joinColumns;
             }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:67,代码来源:XmlDriver.php

示例4: evaluatePropertyAnnotations


//.........这里部分代码省略.........
             if ($orderByAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
                 $mapping['orderBy'] = $orderByAnnotation->value;
             }
             $metadata->mapOneToMany($mapping);
         } elseif ($manyToOneAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToOne')) {
             if ($manyToOneAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $manyToOneAnnotation->targetEntity;
             }
             $mapping['joinColumns'] = $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property);
             if ($manyToOneAnnotation->cascade) {
                 $mapping['cascade'] = $manyToOneAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = array('persist');
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = array('all');
             }
             $mapping['inversedBy'] = $manyToOneAnnotation->inversedBy;
             $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAnnotation->fetch);
             $metadata->mapManyToOne($mapping);
         } elseif ($manyToManyAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToMany')) {
             if ($manyToManyAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $manyToManyAnnotation->targetEntity;
             } elseif (isset($propertyMetaData['elementType'])) {
                 $mapping['targetEntity'] = $propertyMetaData['elementType'];
             }
             /** @var JoinTable $joinTableAnnotation */
             if ($joinTableAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinTable')) {
                 $joinTable = $this->evaluateJoinTableAnnotation($joinTableAnnotation, $property, $className, $mapping);
             } else {
                 $joinColumns = array(array('name' => null, 'referencedColumnName' => null));
                 $joinTable = array('name' => $this->inferJoinTableNameFromClassAndPropertyName($className, $property->getName()), 'joinColumns' => $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property, self::MAPPING_MM_REGULAR), 'inverseJoinColumns' => $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property));
             }
             $mapping['joinTable'] = $joinTable;
             $mapping['mappedBy'] = $manyToManyAnnotation->mappedBy;
             $mapping['inversedBy'] = $manyToManyAnnotation->inversedBy;
             if ($manyToManyAnnotation->cascade) {
                 $mapping['cascade'] = $manyToManyAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = array('persist');
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = array('all');
             }
             $mapping['indexBy'] = $manyToManyAnnotation->indexBy;
             $mapping['orphanRemoval'] = $manyToManyAnnotation->orphanRemoval;
             $mapping['fetch'] = $this->getFetchMode($className, $manyToManyAnnotation->fetch);
             if ($orderByAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
                 $mapping['orderBy'] = $orderByAnnotation->value;
             }
             $metadata->mapManyToMany($mapping);
         } else {
             $mapping['nullable'] = false;
             /** @var Column $columnAnnotation */
             if ($columnAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Column')) {
                 $mapping = $this->addColumnToMappingArray($columnAnnotation, $mapping);
             }
             if (!isset($mapping['type'])) {
                 switch ($propertyMetaData['type']) {
                     case 'DateTime':
                         $mapping['type'] = 'datetime';
                         break;
                     case 'string':
                     case 'integer':
                     case 'boolean':
                     case 'float':
                     case 'array':
                         $mapping['type'] = $propertyMetaData['type'];
                         break;
                     default:
                         if (strpos($propertyMetaData['type'], '\\') !== false) {
                             if ($this->reflectionService->isClassAnnotatedWith($propertyMetaData['type'], \TYPO3\Flow\Annotations\ValueObject::class)) {
                                 $mapping['type'] = 'object';
                             } elseif (class_exists($propertyMetaData['type'])) {
                                 throw MappingException::missingRequiredOption($property->getName(), 'OneToOne', sprintf('The property "%s" in class "%s" has a non standard data type and doesn\'t define the type of the relation. You have to use one of these annotations: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany', $property->getName(), $className));
                             }
                         } else {
                             throw MappingException::propertyTypeIsRequired($className, $property->getName());
                         }
                 }
             }
             if ($this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id') !== null) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\GeneratedValue')) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . strtoupper($generatedValueAnnotation->strategy)));
             }
             if ($this->reflectionService->isPropertyAnnotatedWith($className, $property->getName(), 'Doctrine\\ORM\\Mapping\\Version')) {
                 $metadata->setVersionMapping($mapping);
             }
             $metadata->mapField($mapping);
             // Check for SequenceGenerator/TableGenerator definition
             if ($seqGeneratorAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\SequenceGenerator')) {
                 $metadata->setSequenceGeneratorDefinition(array('sequenceName' => $seqGeneratorAnnotation->sequenceName, 'allocationSize' => $seqGeneratorAnnotation->allocationSize, 'initialValue' => $seqGeneratorAnnotation->initialValue));
             } elseif ($this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\TableGenerator') !== null) {
                 throw MappingException::tableIdGeneratorNotImplemented($className);
             } elseif ($customGeneratorAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\CustomIdGenerator')) {
                 $metadata->setCustomGeneratorDefinition(array('class' => $customGeneratorAnnotation->class));
             }
         }
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:101,代码来源:FlowAnnotationDriver.php

示例5: loadMetadataForClass


//.........这里部分代码省略.........
             $metadata->table['uniqueConstraints'][$unique['name']] = array('columns' => $columns);
         }
     }
     $associationIds = array();
     if (isset($element['id'])) {
         // Evaluate identifier settings
         foreach ($element['id'] as $name => $idElement) {
             if (isset($idElement['associationKey']) && $idElement['associationKey'] == true) {
                 $associationIds[$name] = true;
                 continue;
             }
             $mapping = array('id' => true, 'fieldName' => $name);
             if (isset($idElement['type'])) {
                 $mapping['type'] = $idElement['type'];
             }
             if (isset($idElement['column'])) {
                 $mapping['columnName'] = $idElement['column'];
             }
             if (isset($idElement['length'])) {
                 $mapping['length'] = $idElement['length'];
             }
             if (isset($idElement['columnDefinition'])) {
                 $mapping['columnDefinition'] = $idElement['columnDefinition'];
             }
             $metadata->mapField($mapping);
             if (isset($idElement['generator'])) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . strtoupper($idElement['generator']['strategy'])));
             }
             // Check for SequenceGenerator/TableGenerator definition
             if (isset($idElement['sequenceGenerator'])) {
                 $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']);
             } else {
                 if (isset($idElement['tableGenerator'])) {
                     throw MappingException::tableIdGeneratorNotImplemented($className);
                 }
             }
         }
     }
     // Evaluate fields
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $name => $fieldMapping) {
             $mapping = array('fieldName' => $name);
             if (isset($fieldMapping['type'])) {
                 $e = explode('(', $fieldMapping['type']);
                 $fieldMapping['type'] = $e[0];
                 $mapping['type'] = $fieldMapping['type'];
                 if (isset($e[1])) {
                     $fieldMapping['length'] = substr($e[1], 0, strlen($e[1]) - 1);
                 }
             }
             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'])));
                 }
             }
             if (isset($fieldMapping['column'])) {
                 $mapping['columnName'] = $fieldMapping['column'];
             }
             if (isset($fieldMapping['length'])) {
                 $mapping['length'] = $fieldMapping['length'];
             }
             if (isset($fieldMapping['precision'])) {
                 $mapping['precision'] = $fieldMapping['precision'];
             }
             if (isset($fieldMapping['scale'])) {
开发者ID:williamamed,项目名称:Raptor2,代码行数:67,代码来源:YamlDriver.php

示例6: loadMetadataForClass


//.........这里部分代码省略.........
         // Check for JoinColumn/JoinColumns annotations
         $joinColumns = array();
         if ($joinColumnAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinColumn')) {
             $joinColumns[] = $this->joinColumnToArray($joinColumnAnnot);
         } else {
             if ($joinColumnsAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinColumns')) {
                 foreach ($joinColumnsAnnot->value as $joinColumn) {
                     $joinColumns[] = $this->joinColumnToArray($joinColumn);
                 }
             }
         }
         // Field can only be annotated with one of:
         // @Column, @OneToOne, @OneToMany, @ManyToOne, @ManyToMany
         if ($columnAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Column')) {
             if ($columnAnnot->type == null) {
                 throw MappingException::propertyTypeIsRequired($className, $property->getName());
             }
             $mapping = $this->columnToArray($property->getName(), $columnAnnot);
             if ($idAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\GeneratedValue')) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
             }
             if ($this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Version')) {
                 $metadata->setVersionMapping($mapping);
             }
             $metadata->mapField($mapping);
             // Check for SequenceGenerator/TableGenerator definition
             if ($seqGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\SequenceGenerator')) {
                 $metadata->setSequenceGeneratorDefinition(array('sequenceName' => $seqGeneratorAnnot->sequenceName, 'allocationSize' => $seqGeneratorAnnot->allocationSize, 'initialValue' => $seqGeneratorAnnot->initialValue));
             } else {
                 if ($this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\TableGenerator')) {
                     throw MappingException::tableIdGeneratorNotImplemented($className);
                 } else {
                     if ($customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\CustomIdGenerator')) {
                         $metadata->setCustomGeneratorDefinition(array('class' => $customGeneratorAnnot->class));
                     }
                 }
             }
         } else {
             if ($oneToOneAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToOne')) {
                 if ($idAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                     $mapping['id'] = true;
                 }
                 $mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
                 $mapping['joinColumns'] = $joinColumns;
                 $mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
                 $mapping['inversedBy'] = $oneToOneAnnot->inversedBy;
                 $mapping['cascade'] = $oneToOneAnnot->cascade;
                 $mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval;
                 $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAnnot->fetch);
                 $metadata->mapOneToOne($mapping);
             } else {
                 if ($oneToManyAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToMany')) {
                     $mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
                     $mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
                     $mapping['cascade'] = $oneToManyAnnot->cascade;
                     $mapping['indexBy'] = $oneToManyAnnot->indexBy;
                     $mapping['orphanRemoval'] = $oneToManyAnnot->orphanRemoval;
                     $mapping['fetch'] = $this->getFetchMode($className, $oneToManyAnnot->fetch);
                     if ($orderByAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
                         $mapping['orderBy'] = $orderByAnnot->value;
                     }
                     $metadata->mapOneToMany($mapping);
                 } else {
开发者ID:aschempp,项目名称:doctrine2,代码行数:67,代码来源:AnnotationDriver.php

示例7: loadMetadataForClass


//.........这里部分代码省略.........
             if (isset($idElement['associationKey']) && $idElement['associationKey'] == true) {
                 $associationIds[$name] = true;
                 continue;
             }
             $mapping = array('id' => true, 'fieldName' => $name);
             if (isset($idElement['type'])) {
                 $mapping['type'] = $idElement['type'];
             }
             if (isset($idElement['column'])) {
                 $mapping['columnName'] = $idElement['column'];
             }
             if (isset($idElement['length'])) {
                 $mapping['length'] = $idElement['length'];
             }
             if (isset($idElement['columnDefinition'])) {
                 $mapping['columnDefinition'] = $idElement['columnDefinition'];
             }
             if (isset($idElement['options'])) {
                 $mapping['options'] = $idElement['options'];
             }
             $metadata->mapField($mapping);
             if (isset($idElement['generator'])) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . strtoupper($idElement['generator']['strategy'])));
             }
             // Check for SequenceGenerator/TableGenerator definition
             if (isset($idElement['sequenceGenerator'])) {
                 $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']);
             } else {
                 if (isset($idElement['customIdGenerator'])) {
                     $customGenerator = $idElement['customIdGenerator'];
                     $metadata->setCustomGeneratorDefinition(array('class' => (string) $customGenerator['class']));
                 } else {
                     if (isset($idElement['tableGenerator'])) {
                         throw MappingException::tableIdGeneratorNotImplemented($className);
                     }
                 }
             }
         }
     }
     // Evaluate fields
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $name => $fieldMapping) {
             $mapping = $this->columnToArray($name, $fieldMapping);
             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'])));
                 }
             }
             if (isset($mapping['version'])) {
                 $metadata->setVersionMapping($mapping);
                 unset($mapping['version']);
             }
             $metadata->mapField($mapping);
         }
     }
     if (isset($element['embedded'])) {
         foreach ($element['embedded'] as $name => $embeddedMapping) {
             $mapping = array('fieldName' => $name, 'class' => $embeddedMapping['class'], 'columnPrefix' => isset($embeddedMapping['columnPrefix']) ? $embeddedMapping['columnPrefix'] : null);
             $metadata->mapEmbedded($mapping);
         }
     }
     // Evaluate oneToOne relationships
     if (isset($element['oneToOne'])) {
         foreach ($element['oneToOne'] as $name => $oneToOneElement) {
             $mapping = array('fieldName' => $name, 'targetEntity' => $oneToOneElement['targetEntity']);
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:67,代码来源:YamlDriver.php

示例8: evaluatePropertyAnnotations


//.........这里部分代码省略.........
                 $mapping['targetEntity'] = $manyToManyAnnotation->targetEntity;
             } elseif (isset($propertyMetaData['elementType'])) {
                 $mapping['targetEntity'] = $propertyMetaData['elementType'];
             }
             /** @var ORM\JoinTable $joinTableAnnotation */
             if ($joinTableAnnotation = $this->reader->getPropertyAnnotation($property, ORM\JoinTable::class)) {
                 $joinTable = $this->evaluateJoinTableAnnotation($joinTableAnnotation, $property, $className, $mapping);
             } else {
                 $joinColumns = [['name' => null, 'referencedColumnName' => null]];
                 $joinTable = ['name' => $this->inferJoinTableNameFromClassAndPropertyName($className, $property->getName()), 'joinColumns' => $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property, self::MAPPING_MM_REGULAR), 'inverseJoinColumns' => $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property)];
             }
             $mapping['joinTable'] = $joinTable;
             $mapping['mappedBy'] = $manyToManyAnnotation->mappedBy;
             $mapping['inversedBy'] = $manyToManyAnnotation->inversedBy;
             if ($manyToManyAnnotation->cascade) {
                 $mapping['cascade'] = $manyToManyAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = ['persist'];
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = ['all'];
             }
             $mapping['indexBy'] = $manyToManyAnnotation->indexBy;
             $mapping['orphanRemoval'] = $manyToManyAnnotation->orphanRemoval;
             $mapping['fetch'] = $this->getFetchMode($className, $manyToManyAnnotation->fetch);
             if ($orderByAnnotation = $this->reader->getPropertyAnnotation($property, ORM\OrderBy::class)) {
                 $mapping['orderBy'] = $orderByAnnotation->value;
             }
             $metadata->mapManyToMany($mapping);
         } elseif ($embeddedAnnotation = $this->reader->getPropertyAnnotation($property, ORM\Embedded::class)) {
             if ($embeddedAnnotation->class) {
                 $mapping['class'] = $embeddedAnnotation->class;
             } else {
                 // This will not happen currently, because "class" argument is required. It would be nice if that could be changed though.
                 $mapping['class'] = $mapping['targetEntity'];
             }
             $mapping['columnPrefix'] = $embeddedAnnotation->columnPrefix;
             $metadata->mapEmbedded($mapping);
         } else {
             $mapping['nullable'] = false;
             /** @var ORM\Column $columnAnnotation */
             if ($columnAnnotation = $this->reader->getPropertyAnnotation($property, ORM\Column::class)) {
                 $mapping = $this->addColumnToMappingArray($columnAnnotation, $mapping);
             }
             if (!isset($mapping['type'])) {
                 switch ($propertyMetaData['type']) {
                     case 'DateTime':
                         $mapping['type'] = 'datetime';
                         break;
                     case 'string':
                     case 'integer':
                     case 'boolean':
                     case 'float':
                     case 'array':
                         $mapping['type'] = $propertyMetaData['type'];
                         break;
                     default:
                         if (strpos($propertyMetaData['type'], '\\') !== false) {
                             if ($this->reflectionService->isClassAnnotatedWith($propertyMetaData['type'], Flow\ValueObject::class)) {
                                 $valueObjectAnnotation = $this->reflectionService->getClassAnnotation($propertyMetaData['type'], Flow\ValueObject::class);
                                 if ($valueObjectAnnotation->embedded === true) {
                                     $mapping['class'] = $propertyMetaData['type'];
                                     $mapping['columnPrefix'] = $mapping['columnName'];
                                     $metadata->mapEmbedded($mapping);
                                     // Leave switch and continue with next property
                                     continue 2;
                                 }
                                 $mapping['type'] = 'object';
                             } elseif (class_exists($propertyMetaData['type'])) {
                                 throw ORM\MappingException::missingRequiredOption($property->getName(), 'OneToOne', sprintf('The property "%s" in class "%s" has a non standard data type and doesn\'t define the type of the relation. You have to use one of these annotations: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany', $property->getName(), $className));
                             }
                         } else {
                             throw ORM\MappingException::propertyTypeIsRequired($className, $property->getName());
                         }
                 }
             }
             if ($this->reader->getPropertyAnnotation($property, ORM\Id::class) !== null) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnotation = $this->reader->getPropertyAnnotation($property, ORM\GeneratedValue::class)) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . strtoupper($generatedValueAnnotation->strategy)));
             }
             if ($this->reflectionService->isPropertyAnnotatedWith($className, $property->getName(), ORM\Version::class)) {
                 $metadata->setVersionMapping($mapping);
             }
             $metadata->mapField($mapping);
             // Check for SequenceGenerator/TableGenerator definition
             if ($seqGeneratorAnnotation = $this->reader->getPropertyAnnotation($property, ORM\SequenceGenerator::class)) {
                 $metadata->setSequenceGeneratorDefinition(['sequenceName' => $seqGeneratorAnnotation->sequenceName, 'allocationSize' => $seqGeneratorAnnotation->allocationSize, 'initialValue' => $seqGeneratorAnnotation->initialValue]);
             } elseif ($this->reader->getPropertyAnnotation($property, ORM\TableGenerator::class) !== null) {
                 throw ORM\MappingException::tableIdGeneratorNotImplemented($className);
             } elseif ($customGeneratorAnnotation = $this->reader->getPropertyAnnotation($property, ORM\CustomIdGenerator::class)) {
                 $metadata->setCustomGeneratorDefinition(['class' => $customGeneratorAnnotation->class]);
             }
         }
         // Evaluate @Cache annotation
         if (($cacheAnnotation = $this->reader->getPropertyAnnotation($property, ORM\Cache::class)) !== null) {
             $metadata->enableAssociationCache($mapping['fieldName'], array('usage' => constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CACHE_USAGE_' . $cacheAnnotation->usage), 'region' => $cacheAnnotation->region));
         }
     }
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:101,代码来源:FlowAnnotationDriver.php

示例9: loadMetadataForClass


//.........这里部分代码省略.........
             }
             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
     foreach ($xmlRoot->id as $idElement) {
         $mapping = array('id' => true, 'fieldName' => (string) $idElement['name'], 'type' => (string) $idElement['type']);
         if (isset($idElement['column'])) {
             $mapping['columnName'] = (string) $idElement['column'];
         }
         $metadata->mapField($mapping);
         if (isset($idElement->generator)) {
             $strategy = isset($idElement->generator['strategy']) ? (string) $idElement->generator['strategy'] : 'AUTO';
             $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $strategy));
         }
         // Check for SequenceGenerator/TableGenerator definition
         if (isset($idElement->{'sequence-generator'})) {
             $seqGenerator = $idElement->{'sequence-generator'};
             $metadata->setSequenceGeneratorDefinition(array('sequenceName' => $seqGenerator->{'sequence-name'}, 'allocationSize' => $seqGenerator->{'allocation-size'}, 'initialValue' => $seqGeneratorAnnot->{'initial-value'}));
         } else {
             if (isset($idElement->{'table-generator'})) {
                 throw MappingException::tableIdGeneratorNotImplemented($className);
             }
         }
     }
     // Evaluate <one-to-one ...> mappings
     if (isset($xmlRoot->{'one-to-one'})) {
         foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) {
             $mapping = array('fieldName' => (string) $oneToOneElement['field'], 'targetEntity' => (string) $oneToOneElement['target-entity']);
             if (isset($oneToOneElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\AssociationMapping::FETCH_' . (string) $oneToOneElement['fetch']);
             }
             if (isset($oneToOneElement['mapped-by'])) {
                 $mapping['mappedBy'] = (string) $oneToOneElement['mapped-by'];
             } else {
                 $joinColumns = array();
                 if (isset($oneToOneElement->{'join-column'})) {
                     $joinColumns[] = $this->_getJoinColumnMapping($oneToOneElement->{'join-column'});
                 } else {
                     if (isset($oneToOneElement->{'join-columns'})) {
                         foreach ($oneToOneElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
                             $joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement);
                         }
                     }
                 }
                 $mapping['joinColumns'] = $joinColumns;
             }
             if (isset($oneToOneElement->cascade)) {
                 $mapping['cascade'] = $this->_getCascadeMappings($oneToOneElement->cascade);
             }
             if (isset($oneToOneElement->{'orphan-removal'})) {
                 $mapping['orphanRemoval'] = (bool) $oneToOneElement->{'orphan-removal'};
             }
             $metadata->mapOneToOne($mapping);
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:67,代码来源:XmlDriver.php

示例10: loadMetadataForClass


//.........这里部分代码省略.........
             if ($columnAnnot->type == null) {
                 throw MappingException::propertyTypeIsRequired($className, $property->getName());
             }
             $mapping['type'] = $columnAnnot->type;
             $mapping['length'] = $columnAnnot->length;
             $mapping['precision'] = $columnAnnot->precision;
             $mapping['scale'] = $columnAnnot->scale;
             $mapping['nullable'] = $columnAnnot->nullable;
             $mapping['unique'] = $columnAnnot->unique;
             if ($columnAnnot->options) {
                 $mapping['options'] = $columnAnnot->options;
             }
             if (isset($columnAnnot->name)) {
                 $mapping['columnName'] = $columnAnnot->name;
             }
             if (isset($columnAnnot->columnDefinition)) {
                 $mapping['columnDefinition'] = $columnAnnot->columnDefinition;
             }
             if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\GeneratedValue')) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
             }
             if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Version')) {
                 $metadata->setVersionMapping($mapping);
             }
             $metadata->mapField($mapping);
             // Check for SequenceGenerator/TableGenerator definition
             if ($seqGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\SequenceGenerator')) {
                 $metadata->setSequenceGeneratorDefinition(array('sequenceName' => $seqGeneratorAnnot->sequenceName, 'allocationSize' => $seqGeneratorAnnot->allocationSize, 'initialValue' => $seqGeneratorAnnot->initialValue));
             } else {
                 if ($tblGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\TableGenerator')) {
                     throw MappingException::tableIdGeneratorNotImplemented($className);
                 }
             }
         } else {
             if ($oneToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToOne')) {
                 $mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
                 $mapping['joinColumns'] = $joinColumns;
                 $mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
                 $mapping['cascade'] = $oneToOneAnnot->cascade;
                 $mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval;
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\AssociationMapping::FETCH_' . $oneToOneAnnot->fetch);
                 $metadata->mapOneToOne($mapping);
             } else {
                 if ($oneToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToMany')) {
                     $mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
                     $mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
                     $mapping['cascade'] = $oneToManyAnnot->cascade;
                     $mapping['orphanRemoval'] = $oneToManyAnnot->orphanRemoval;
                     $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\AssociationMapping::FETCH_' . $oneToManyAnnot->fetch);
                     $metadata->mapOneToMany($mapping);
                 } else {
                     if ($manyToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToOne')) {
                         $mapping['joinColumns'] = $joinColumns;
                         $mapping['cascade'] = $manyToOneAnnot->cascade;
                         $mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
                         $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\AssociationMapping::FETCH_' . $manyToOneAnnot->fetch);
                         $metadata->mapManyToOne($mapping);
                     } else {
                         if ($manyToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToMany')) {
                             $joinTable = array();
                             if ($joinTableAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinTable')) {
                                 $joinTable = array('name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema);
                                 foreach ($joinTableAnnot->joinColumns as $joinColumn) {
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:67,代码来源:AnnotationDriver.php


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