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


PHP ClassMetadataInfo::isInheritedField方法代码示例

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


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

示例1: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Timestampable\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         if ($timestampable = $reader->getPropertyAnnotation($property, self::ANNOTATION_TIMESTAMPABLE)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             if (!in_array($timestampable->on, array('update', 'create', 'change'))) {
                 throw MappingException::triggerTypeInvalid($field, $meta->name);
             }
             if ($timestampable->on == 'change') {
                 if (!isset($timestampable->field) || !isset($timestampable->value)) {
                     throw MappingException::parametersMissing($field, $meta->name);
                 }
                 $field = array('field' => $field, 'trackedField' => $timestampable->field, 'value' => $timestampable->value);
             }
             // properties are unique and mapper checks that, no risk here
             $config[$timestampable->on][] = $field;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:37,代码来源:Annotation.php

示例2: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Tree\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         // left
         if ($left = $reader->getPropertyAnnotation($property, self::ANNOTATION_LEFT)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['left'] = $field;
         }
         // right
         if ($right = $reader->getPropertyAnnotation($property, self::ANNOTATION_RIGHT)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['right'] = $field;
         }
         // ancestor/parent
         if ($parent = $reader->getPropertyAnnotation($property, self::ANNOTATION_PARENT)) {
             $field = $property->getName();
             if (!$meta->isSingleValuedAssociation($field)) {
                 throw MappingException::parentFieldNotMappedOrRelated($field, $meta->name);
             }
             $config['parent'] = $field;
         }
         // level
         if ($parent = $reader->getPropertyAnnotation($property, self::ANNOTATION_LEVEL)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['level'] = $field;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:58,代码来源:Annotation.php

示例3: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Translatable\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // class annotations
     $classAnnotations = $reader->getClassAnnotations($class);
     if (isset($classAnnotations[self::ANNOTATION_ENTITY_CLASS])) {
         $annot = $classAnnotations[self::ANNOTATION_ENTITY_CLASS];
         if (!class_exists($annot->class)) {
             throw MappingException::translationClassNotFound($annot->class);
         }
         $config['translationClass'] = $annot->class;
     }
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         // translatable property
         if ($translatable = $reader->getPropertyAnnotation($property, self::ANNOTATION_TRANSLATABLE)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             // fields cannot be overrided and throws mapping exception
             $config['fields'][] = $field;
         }
         // locale property
         if ($locale = $reader->getPropertyAnnotation($property, self::ANNOTATION_LOCALE)) {
             $field = $property->getName();
             if ($meta->hasField($field)) {
                 throw MappingException::fieldMustNotBeMapped($field, $meta->name);
             }
             $config['locale'] = $field;
         } elseif ($language = $reader->getPropertyAnnotation($property, self::ANNOTATION_LANGUAGE)) {
             $field = $property->getName();
             if ($meta->hasField($field)) {
                 throw MappingException::fieldMustNotBeMapped($field, $meta->name);
             }
             $config['locale'] = $field;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:52,代码来源:Annotation.php

示例4: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Sluggable\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         // sluggable property
         if ($sluggable = $reader->getPropertyAnnotation($property, self::ANNOTATION_SLUGGABLE)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['fields'][] = $field;
         }
         // slug property
         if ($slug = $reader->getPropertyAnnotation($property, self::ANNOTATION_SLUG)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::slugFieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             if (isset($config['slug'])) {
                 throw MappingException::slugFieldIsDuplicate($field, $meta->name);
             }
             $config['slug'] = $field;
             $config['style'] = $slug->style;
             $config['updatable'] = $slug->updatable;
             $config['unique'] = $slug->unique;
             $config['separator'] = $slug->separator;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:46,代码来源:Annotation.php

示例5: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $class = $metadata->getReflectionClass();
     if (!$class) {
         // this happens when running annotation driver in combination with
         // static reflection services. This is not the nicest fix
         $class = new \ReflectionClass($metadata->name);
     }
     $classAnnotations = $this->_reader->getClassAnnotations($class);
     // Compatibility with Doctrine Common 3.x
     if ($classAnnotations && is_int(key($classAnnotations))) {
         foreach ($classAnnotations as $annot) {
             $classAnnotations[get_class($annot)] = $annot;
         }
     }
     // Evaluate Entity annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Entity'])) {
         $entityAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Entity'];
         if ($entityAnnot->repositoryClass !== null) {
             $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
         }
         if ($entityAnnot->readOnly) {
             $metadata->markReadOnly();
         }
     } else {
         if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\MappedSuperclass'])) {
             $mappedSuperclassAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\MappedSuperclass'];
             $metadata->setCustomRepositoryClass($mappedSuperclassAnnot->repositoryClass);
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate Table annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Table'])) {
         $tableAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Table'];
         $primaryTable = array('name' => $tableAnnot->name, 'schema' => $tableAnnot->schema);
         if ($tableAnnot->indexes !== null) {
             foreach ($tableAnnot->indexes as $indexAnnot) {
                 $primaryTable['indexes'][$indexAnnot->name] = array('columns' => $indexAnnot->columns);
             }
         }
         if ($tableAnnot->uniqueConstraints !== null) {
             foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) {
                 $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array('columns' => $uniqueConstraint->columns);
             }
         }
         if ($tableAnnot->options !== null) {
             $primaryTable['options'] = $tableAnnot->options;
         }
         $metadata->setPrimaryTable($primaryTable);
     }
     // Evaluate NamedQueries annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\NamedQueries'])) {
         $namedQueriesAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\NamedQueries'];
         if (!is_array($namedQueriesAnnot->value)) {
             throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations.");
         }
         foreach ($namedQueriesAnnot->value as $namedQuery) {
             if (!$namedQuery instanceof \Doctrine\ORM\Mapping\NamedQuery) {
                 throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations.");
             }
             $metadata->addNamedQuery(array('name' => $namedQuery->name, 'query' => $namedQuery->query));
         }
     }
     // Evaluate InheritanceType annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'])) {
         $inheritanceTypeAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'];
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
         if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
             // Evaluate DiscriminatorColumn annotation
             if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'])) {
                 $discrColumnAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'];
                 $metadata->setDiscriminatorColumn(array('name' => $discrColumnAnnot->name, 'type' => $discrColumnAnnot->type, 'length' => $discrColumnAnnot->length, 'columnDefinition' => $discrColumnAnnot->columnDefinition));
             } else {
                 $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255));
             }
             // Evaluate DiscriminatorMap annotation
             if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'])) {
                 $discrMapAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'];
                 $metadata->setDiscriminatorMap($discrMapAnnot->value);
             }
         }
     }
     // Evaluate DoctrineChangeTrackingPolicy annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'])) {
         $changeTrackingAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'];
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
     }
     // Evaluate annotations on properties/fields
     foreach ($class->getProperties() as $property) {
         if ($metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->name) || $metadata->isInheritedAssociation($property->name)) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         // Check for JoinColummn/JoinColumns annotations
//.........这里部分代码省略.........
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:101,代码来源:AnnotationDriver.php

示例6: evaluatePropertyAnnotations

 /**
  * Evaluate the property annotations and amend the metadata accordingly.
  *
  * @param ClassMetadataInfo $metadata
  * @return void
  * @throws MappingException
  */
 protected function evaluatePropertyAnnotations(ClassMetadataInfo $metadata)
 {
     $className = $metadata->name;
     $class = $metadata->getReflectionClass();
     $classSchema = $this->getClassSchema($className);
     foreach ($class->getProperties() as $property) {
         if (!$classSchema->hasProperty($property->getName()) || $classSchema->isPropertyTransient($property->getName()) || $metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->getName()) || $metadata->isInheritedAssociation($property->getName())) {
             continue;
         }
         $propertyMetaData = $classSchema->getProperty($property->getName());
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         $mapping['columnName'] = strtolower($property->getName());
         $mapping['targetEntity'] = $propertyMetaData['type'];
         $joinColumns = $this->evaluateJoinColumnAnnotations($property);
         // Field can only be annotated with one of:
         // @OneToOne, @OneToMany, @ManyToOne, @ManyToMany, @Column (optional)
         if ($oneToOneAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToOne')) {
             if ($oneToOneAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $oneToOneAnnotation->targetEntity;
             }
             if ($oneToOneAnnotation->inversedBy !== null || $oneToOneAnnotation->mappedBy === null) {
                 $mapping['joinColumns'] = $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property);
             }
             $mapping['mappedBy'] = $oneToOneAnnotation->mappedBy;
             $mapping['inversedBy'] = $oneToOneAnnotation->inversedBy;
             if ($oneToOneAnnotation->cascade) {
                 $mapping['cascade'] = $oneToOneAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = array('persist');
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = array('all');
             }
             if ($oneToOneAnnotation->orphanRemoval) {
                 $mapping['orphanRemoval'] = $oneToOneAnnotation->orphanRemoval;
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false && $this->isValueObject($mapping['targetEntity'], $className) === false) {
                 $mapping['orphanRemoval'] = true;
             }
             $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAnnotation->fetch);
             $metadata->mapOneToOne($mapping);
         } elseif ($oneToManyAnnotation = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToMany')) {
             $mapping['mappedBy'] = $oneToManyAnnotation->mappedBy;
             if ($oneToManyAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $oneToManyAnnotation->targetEntity;
             } elseif (isset($propertyMetaData['elementType'])) {
                 $mapping['targetEntity'] = $propertyMetaData['elementType'];
             }
             if ($oneToManyAnnotation->cascade) {
                 $mapping['cascade'] = $oneToManyAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = array('persist');
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = array('all');
             }
             $mapping['indexBy'] = $oneToManyAnnotation->indexBy;
             if ($oneToManyAnnotation->orphanRemoval) {
                 $mapping['orphanRemoval'] = $oneToManyAnnotation->orphanRemoval;
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false && $this->isValueObject($mapping['targetEntity'], $className) === false) {
                 $mapping['orphanRemoval'] = true;
             }
             $mapping['fetch'] = $this->getFetchMode($className, $oneToManyAnnotation->fetch);
             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));
             }
//.........这里部分代码省略.........
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:101,代码来源:FlowAnnotationDriver.php

示例7: evaluatePropertyAnnotations

 /**
  * Evaluate the property annotations and amend the metadata accordingly.
  *
  * @param ORM\ClassMetadataInfo $metadata
  * @return void
  * @throws ORM\MappingException
  */
 protected function evaluatePropertyAnnotations(ORM\ClassMetadataInfo $metadata)
 {
     $className = $metadata->name;
     $class = $metadata->getReflectionClass();
     $classSchema = $this->getClassSchema($className);
     foreach ($class->getProperties() as $property) {
         if (!$classSchema->hasProperty($property->getName()) || $classSchema->isPropertyTransient($property->getName()) || $metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->getName()) || $metadata->isInheritedAssociation($property->getName()) || $metadata->isInheritedEmbeddedClass($property->getName())) {
             continue;
         }
         $propertyMetaData = $classSchema->getProperty($property->getName());
         $mapping = [];
         $mapping['fieldName'] = $property->getName();
         $mapping['columnName'] = strtolower($property->getName());
         $mapping['targetEntity'] = $propertyMetaData['type'];
         $joinColumns = $this->evaluateJoinColumnAnnotations($property);
         // Field can only be annotated with one of:
         // @OneToOne, @OneToMany, @ManyToOne, @ManyToMany, @Column (optional)
         if ($oneToOneAnnotation = $this->reader->getPropertyAnnotation($property, ORM\OneToOne::class)) {
             if ($this->reader->getPropertyAnnotation($property, ORM\Id::class) !== null) {
                 $mapping['id'] = true;
             }
             if ($oneToOneAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $oneToOneAnnotation->targetEntity;
             }
             if ($oneToOneAnnotation->inversedBy !== null || $oneToOneAnnotation->mappedBy === null) {
                 $mapping['joinColumns'] = $this->buildJoinColumnsIfNeeded($joinColumns, $mapping, $property);
             }
             $mapping['mappedBy'] = $oneToOneAnnotation->mappedBy;
             $mapping['inversedBy'] = $oneToOneAnnotation->inversedBy;
             if ($oneToOneAnnotation->cascade) {
                 $mapping['cascade'] = $oneToOneAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = ['persist'];
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = ['all'];
             }
             if ($oneToOneAnnotation->orphanRemoval) {
                 $mapping['orphanRemoval'] = $oneToOneAnnotation->orphanRemoval;
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false && $this->isValueObject($mapping['targetEntity'], $className) === false) {
                 $mapping['orphanRemoval'] = true;
             }
             $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAnnotation->fetch);
             $metadata->mapOneToOne($mapping);
         } elseif ($oneToManyAnnotation = $this->reader->getPropertyAnnotation($property, ORM\OneToMany::class)) {
             $mapping['mappedBy'] = $oneToManyAnnotation->mappedBy;
             if ($oneToManyAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $oneToManyAnnotation->targetEntity;
             } elseif (isset($propertyMetaData['elementType'])) {
                 $mapping['targetEntity'] = $propertyMetaData['elementType'];
             }
             if ($oneToManyAnnotation->cascade) {
                 $mapping['cascade'] = $oneToManyAnnotation->cascade;
             } elseif ($this->isValueObject($mapping['targetEntity'], $className)) {
                 $mapping['cascade'] = ['persist'];
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = ['all'];
             }
             $mapping['indexBy'] = $oneToManyAnnotation->indexBy;
             if ($oneToManyAnnotation->orphanRemoval) {
                 $mapping['orphanRemoval'] = $oneToManyAnnotation->orphanRemoval;
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false && $this->isValueObject($mapping['targetEntity'], $className) === false) {
                 $mapping['orphanRemoval'] = true;
             }
             $mapping['fetch'] = $this->getFetchMode($className, $oneToManyAnnotation->fetch);
             if ($orderByAnnotation = $this->reader->getPropertyAnnotation($property, ORM\OrderBy::class)) {
                 $mapping['orderBy'] = $orderByAnnotation->value;
             }
             $metadata->mapOneToMany($mapping);
         } elseif ($manyToOneAnnotation = $this->reader->getPropertyAnnotation($property, ORM\ManyToOne::class)) {
             if ($this->reader->getPropertyAnnotation($property, ORM\Id::class) !== null) {
                 $mapping['id'] = true;
             }
             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'] = ['persist'];
             } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === false) {
                 $mapping['cascade'] = ['all'];
             }
             $mapping['inversedBy'] = $manyToOneAnnotation->inversedBy;
             $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAnnotation->fetch);
             $metadata->mapManyToOne($mapping);
         } elseif ($manyToManyAnnotation = $this->reader->getPropertyAnnotation($property, ORM\ManyToMany::class)) {
             if ($manyToManyAnnotation->targetEntity) {
                 $mapping['targetEntity'] = $manyToManyAnnotation->targetEntity;
             } elseif (isset($propertyMetaData['elementType'])) {
                 $mapping['targetEntity'] = $propertyMetaData['elementType'];
             }
             /** @var ORM\JoinTable $joinTableAnnotation */
//.........这里部分代码省略.........
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:101,代码来源:FlowAnnotationDriver.php

示例8: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $class = $metadata->getReflectionClass();
     $classAnnotations = $this->_reader->getClassAnnotations($class);
     // Evaluate Entity annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Entity'])) {
         $entityAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Entity'];
         $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
     } else {
         if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\MappedSuperclass'])) {
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate DoctrineTable annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Table'])) {
         $tableAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Table'];
         $primaryTable = array('name' => $tableAnnot->name, 'schema' => $tableAnnot->schema);
         if ($tableAnnot->indexes !== null) {
             foreach ($tableAnnot->indexes as $indexAnnot) {
                 $primaryTable['indexes'][$indexAnnot->name] = array('columns' => $indexAnnot->columns);
             }
         }
         if ($tableAnnot->uniqueConstraints !== null) {
             foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) {
                 $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array('columns' => $uniqueConstraint->columns);
             }
         }
         $metadata->setPrimaryTable($primaryTable);
     }
     // Evaluate InheritanceType annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'])) {
         $inheritanceTypeAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'];
         $metadata->setInheritanceType(constant('\\Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
     }
     // Evaluate DiscriminatorColumn annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'])) {
         $discrColumnAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'];
         $metadata->setDiscriminatorColumn(array('name' => $discrColumnAnnot->name, 'type' => $discrColumnAnnot->type, 'length' => $discrColumnAnnot->length));
     }
     // Evaluate DiscriminatorMap annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'])) {
         $discrMapAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'];
         $metadata->setDiscriminatorMap($discrMapAnnot->value);
     }
     // Evaluate DoctrineChangeTrackingPolicy annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'])) {
         $changeTrackingAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'];
         $metadata->setChangeTrackingPolicy($changeTrackingAnnot->value);
     }
     // Evaluate annotations on properties/fields
     foreach ($class->getProperties() as $property) {
         if ($metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->name) || $metadata->isInheritedAssociation($property->name)) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         // Check for JoinColummn/JoinColumns annotations
         $joinColumns = array();
         if ($joinColumnAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinColumn')) {
             $joinColumns[] = array('name' => $joinColumnAnnot->name, 'referencedColumnName' => $joinColumnAnnot->referencedColumnName, 'unique' => $joinColumnAnnot->unique, 'nullable' => $joinColumnAnnot->nullable, 'onDelete' => $joinColumnAnnot->onDelete, 'onUpdate' => $joinColumnAnnot->onUpdate, 'columnDefinition' => $joinColumnAnnot->columnDefinition);
         } else {
             if ($joinColumnsAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinColumns')) {
                 foreach ($joinColumnsAnnot->value as $joinColumn) {
                     $joinColumns[] = array('name' => $joinColumn->name, 'referencedColumnName' => $joinColumn->referencedColumnName, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'onUpdate' => $joinColumn->onUpdate, 'columnDefinition' => $joinColumn->columnDefinition);
                 }
             }
         }
         // 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['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')) {
//.........这里部分代码省略.........
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:101,代码来源:AnnotationDriver.php


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