本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::mapEmbedded方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::mapEmbedded方法的具体用法?PHP ClassMetadataInfo::mapEmbedded怎么用?PHP ClassMetadataInfo::mapEmbedded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadataInfo
的用法示例。
在下文中一共展示了ClassMetadataInfo::mapEmbedded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addEmbedded
/**
* Adds and embedded class
*
* @param string $fieldName
* @param string $class
* @param string|null $columnPrefix
*
* @return $this
*/
public function addEmbedded($fieldName, $class, $columnPrefix = null)
{
$this->cm->mapEmbedded(['fieldName' => $fieldName, 'class' => $class, 'columnPrefix' => $columnPrefix]);
return $this;
}
示例2: mapNestedEmbedded
/**
* @param string $fieldName
* @param ClassMetadataInfo $classMetadata
* @param ClassMetadataInfo $embeddableMetadata
*/
private function mapNestedEmbedded($fieldName, ClassMetadataInfo $classMetadata, ClassMetadataInfo $embeddableMetadata)
{
foreach ($embeddableMetadata->embeddedClasses as $property => $embeddableClass) {
$classMetadata->mapEmbedded(array('fieldName' => $fieldName . '.' . $property, 'class' => $embeddableClass['class'], 'columnPrefix' => $embeddableClass['columnPrefix'], 'declaredField' => $embeddableClass['declaredField'] ? $fieldName . '.' . $embeddableClass['declaredField'] : $fieldName, 'originalField' => $embeddableClass['originalField'] ?: $property));
}
}
示例3: 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));
}
}
}