本文整理汇总了PHP中Doctrine\ODM\MongoDB\MongoDBException::classIsNotAValidDocument方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDBException::classIsNotAValidDocument方法的具体用法?PHP MongoDBException::classIsNotAValidDocument怎么用?PHP MongoDBException::classIsNotAValidDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\MongoDBException
的用法示例。
在下文中一共展示了MongoDBException::classIsNotAValidDocument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadMetadataForClass
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, ClassMetadataInfo $class)
{
foreach ($this->drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
$driver->loadMetadataForClass($className, $class);
return;
}
}
throw MongoDBException::classIsNotAValidDocument($className);
}
示例2: loadMetadataForClass
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, ClassMetadataInfo $class)
{
$reflClass = $class->getReflectionClass();
$classAnnotations = $this->reader->getClassAnnotations($reflClass);
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Document'])) {
$documentAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Document'];
} elseif (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\MappedSuperclass'])) {
$documentAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\MappedSuperclass'];
$class->isMappedSuperclass = true;
} elseif (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbeddedDocument'])) {
$documentAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbeddedDocument'];
$class->isEmbeddedDocument = true;
} else {
throw MongoDBException::classIsNotAValidDocument($className);
}
if (isset($documentAnnot->db)) {
$class->setDatabase($documentAnnot->db);
}
if (isset($documentAnnot->collection)) {
$class->setCollection($documentAnnot->collection);
}
if (isset($documentAnnot->repositoryClass)) {
$class->setCustomRepositoryClass($documentAnnot->repositoryClass);
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Indexes'])) {
$indexes = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Indexes']->value;
$indexes = is_array($indexes) ? $indexes : array($indexes);
foreach ($indexes as $index) {
$this->addIndex($class, $index);
}
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Index'])) {
$index = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Index'];
$this->addIndex($class, $index);
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\UniqueIndex'])) {
$index = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\UniqueIndex'];
$this->addIndex($class, $index);
}
if (isset($documentAnnot->indexes)) {
foreach ($documentAnnot->indexes as $index) {
$this->addIndex($class, $index);
}
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\InheritanceType'];
$class->setInheritanceType(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorField'])) {
$discrFieldAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorField'];
$class->setDiscriminatorField(array('fieldName' => $discrFieldAnnot->fieldName));
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorMap'])) {
$discrMapAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorMap'];
$class->setDiscriminatorMap($discrMapAnnot->value);
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorValue'])) {
$discrValueAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorValue'];
$class->setDiscriminatorValue($discrValueAnnot->value);
}
if (isset($classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ChangeTrackingPolicy'])) {
$changeTrackingAnnot = $classAnnotations['Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ChangeTrackingPolicy'];
$class->setChangeTrackingPolicy(constant('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
}
$methods = $reflClass->getMethods();
foreach ($reflClass->getProperties() as $property) {
if ($class->isMappedSuperclass && !$property->isPrivate() || $class->isInheritedField($property->name)) {
continue;
}
$mapping = array();
$mapping['fieldName'] = $property->getName();
if ($alsoLoad = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\AlsoLoad')) {
$mapping['alsoLoadFields'] = (array) $alsoLoad->value;
}
if ($notSaved = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\NotSaved')) {
$mapping['notSaved'] = true;
}
if ($versionAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Version')) {
$mapping['version'] = true;
}
if ($versionAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Lock')) {
$mapping['lock'] = true;
}
$indexes = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Indexes');
$indexes = $indexes ? $indexes : array();
if ($index = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Index')) {
$indexes[] = $index;
}
if ($index = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\UniqueIndex')) {
$indexes[] = $index;
}
foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
if ($fieldAnnot instanceof \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractField) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$class->mapField($mapping);
}
}
//.........这里部分代码省略.........
示例3: loadMetadataForClass
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, ClassMetadataInfo $class)
{
$reflClass = $class->getReflectionClass();
$documentAnnots = array();
foreach ($this->reader->getClassAnnotations($reflClass) as $annot) {
foreach (self::$documentAnnotationClasses as $i => $annotClass) {
if ($annot instanceof $annotClass) {
$documentAnnots[$i] = $annot;
continue 2;
}
}
// 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));
}
}
if (!$documentAnnots) {
throw MongoDBException::classIsNotAValidDocument($className);
}
// find the winning document annotation
ksort($documentAnnots);
$documentAnnot = reset($documentAnnots);
if ($documentAnnot instanceof ODM\MappedSuperclass) {
$class->isMappedSuperclass = true;
} elseif ($documentAnnot instanceof ODM\EmbeddedDocument) {
$class->isEmbeddedDocument = true;
}
if (isset($documentAnnot->db)) {
$class->setDatabase($documentAnnot->db);
}
if (isset($documentAnnot->collection)) {
$class->setCollection($documentAnnot->collection);
}
if (isset($documentAnnot->repositoryClass)) {
$class->setCustomRepositoryClass($documentAnnot->repositoryClass);
}
if (isset($documentAnnot->indexes)) {
foreach ($documentAnnot->indexes as $index) {
$this->addIndex($class, $index);
}
}
foreach ($reflClass->getProperties() as $property) {
if ($class->isMappedSuperclass && !$property->isPrivate() || $class->isInheritedField($property->name)) {
continue;
}
$indexes = array();
$mapping = array('fieldName' => $property->getName());
$fieldAnnot = null;
foreach ($this->reader->getPropertyAnnotations($property) as $annot) {
if ($annot instanceof ODM\AbstractField) {
$fieldAnnot = $annot;
}
if ($annot instanceof ODM\AbstractIndex) {
$indexes[] = $annot;
}
if ($annot instanceof ODM\Indexes) {
foreach (is_array($annot->value) ? $annot->value : array($annot->value) as $index) {
$indexes[] = $index;
}
} elseif ($annot instanceof ODM\AlsoLoad) {
$mapping['alsoLoadFields'] = (array) $annot->value;
} elseif ($annot instanceof ODM\Version) {
$mapping['version'] = true;
} elseif ($annot instanceof ODM\Lock) {
$mapping['lock'] = true;
}
}
if ($fieldAnnot) {
$mapping = array_replace($mapping, (array) $fieldAnnot);
$class->mapField($mapping);
}
//.........这里部分代码省略.........