Created
July 6, 2011 08:48
-
-
Save bartrail/1066856 to your computer and use it in GitHub Desktop.
loadMetadataForClass in Doctrine MongoDB ODM AnnotationDriver.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritdoc} | |
*/ | |
public function loadMetadataForClass($className, ClassMetadataInfo $class) | |
{ | |
$reflClass = $class->getReflectionClass(); | |
$documentAnnots = array(); | |
foreach ($this->reader->getClassAnnotations($reflClass) as $annot) { | |
$nextAnnotation = false; | |
foreach (self::$documentAnnotationClasses as $i => $annotClass) { | |
if ($annot instanceof $annotClass) { | |
$documentAnnots[$i] = $annot; | |
$nextAnnotation = true; | |
break; | |
// goto next_annotation; | |
} | |
} | |
if($nextAnnotation == false) { | |
// non-document class annotations | |
if ($annot instanceof ODM\AbstractIndex) { | |
$this->addIndex($class, $annot); | |
} | |
if ($annot instanceof ODM\Indexes) { | |
foreach (is_array($annot->value) ? $annot->value : array($annot->value) as $index) { | |
$this->addIndex($class, $index); | |
} | |
} elseif ($annot instanceof ODM\InheritanceType) { | |
$class->setInheritanceType(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::INHERITANCE_TYPE_'.$annot->value)); | |
} elseif ($annot instanceof ODM\DiscriminatorField) { | |
$class->setDiscriminatorField(array('fieldName' => $annot->fieldName)); | |
} elseif ($annot instanceof ODM\DiscriminatorMap) { | |
$class->setDiscriminatorMap($annot->value); | |
} elseif ($annot instanceof ODM\DiscriminatorValue) { | |
$class->setDiscriminatorValue($annot->value); | |
} elseif ($annot instanceof ODM\ChangeTrackingPolicy) { | |
$class->setChangeTrackingPolicy(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::CHANGETRACKING_'.$annot->value)); | |
} | |
} | |
// next_annotation: | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment