本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::getAssociationMapping方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::getAssociationMapping方法的具体用法?PHP ClassMetadataInfo::getAssociationMapping怎么用?PHP ClassMetadataInfo::getAssociationMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadataInfo
的用法示例。
在下文中一共展示了ClassMetadataInfo::getAssociationMapping方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getORMTransformerInfo
/**
* @param ColumnInfoInterface $columnInfo
* @param ORMClassMetadataInfo $metadata
*
* @return array
*/
private function getORMTransformerInfo(ColumnInfoInterface $columnInfo, ORMClassMetadataInfo $metadata)
{
if (!$metadata->hasAssociation($columnInfo->getPropertyPath())) {
return;
}
$mapping = $metadata->getAssociationMapping($columnInfo->getPropertyPath());
if (!$this->doctrine->getRepository($mapping['targetEntity']) instanceof ReferableEntityRepositoryInterface) {
return;
}
return array($this->transformer, array('class' => $mapping['targetEntity'], 'multiple' => ORMClassMetadataInfo::MANY_TO_MANY === $mapping['type']));
}
示例2: getAssocicationHandler
/**
* @param $association
* @param ClassMetadataInfo $meta
* @return ManyToMany|ManyToOne|OneToMany|OneToOne
* @throws \Doctrine\ORM\Mapping\MappingException
*/
private function getAssocicationHandler($association, ClassMetadataInfo $meta)
{
$mapping = $meta->getAssociationMapping($association);
switch ($mapping['type']) {
case ClassMetadataInfo::ONE_TO_ONE:
$assoc = new OneToOne($this->accessor, $this);
break;
case ClassMetadataInfo::MANY_TO_ONE:
$assoc = new ManyToOne($this->accessor, $this);
break;
case ClassMetadataInfo::ONE_TO_MANY:
$assoc = new OneToMany($this->accessor, $this);
break;
case ClassMetadataInfo::MANY_TO_MANY:
$assoc = new ManyToMany($this->accessor, $this);
break;
}
return $assoc;
}
示例3: findTranslationsCollection
protected function findTranslationsCollection(Reader $reader, ClassMetadataInfo $classMetadata)
{
foreach ($classMetadata->getReflectionClass()->getProperties() as $property) {
$annotation = $reader->getPropertyAnnotation($property, 'Webfactory\\Bundle\\PolyglotBundle\\Annotation\\TranslationCollection');
if ($annotation !== null) {
$property->setAccessible(true);
$this->translationsCollectionProperty = $property;
$am = $classMetadata->getAssociationMapping($property->getName());
$this->parseTranslationsEntity($reader, $am['targetEntity']);
$translationMappingProperty = $this->translationClass->getProperty($am['mappedBy']);
$translationMappingProperty->setAccessible(true);
$this->translationMappingProperty = $translationMappingProperty;
break;
}
}
}
示例4: isUniDirectional
private function isUniDirectional()
{
$mapping = $this->meta->getAssociationMapping($this->association);
return null === $mapping['mappedBy'] && null === $mapping['inversedBy'];
}
示例5: mapValue
/**
* @param ClassMetadataInfo $meta
* @param string $field
* @param mixed $value
*/
protected function mapValue(ClassMetadataInfo $meta, $field, &$value)
{
if ($meta->isSingleValuedAssociation($field)) {
$mapping = $meta->getAssociationMapping($field);
$value = $value ? $this->em->getReference($mapping['targetEntity'], $value) : null;
return;
}
$type = Type::getType($meta->fieldMappings[$field]['type']);
$value = $type->convertToPHPValue($value, $this->em->getConnection()->getDatabasePlatform());
}
示例6: guessAssociation
/**
* @param ClassMetadataInfo $metadata
* @param Field $field
* @param SchemaContainer $schemaContainer
* @return TypeGuess
* @throws MappingException
*/
private function guessAssociation(ClassMetadataInfo $metadata, Field $field, SchemaContainer $schemaContainer)
{
$property = $field->getProperty() ?: $field->getName();
$multiple = $metadata->isCollectionValuedAssociation($property);
$mapping = $metadata->getAssociationMapping($property);
foreach ($schemaContainer->getTypes() as $type) {
$containerContext = new ContainerContext($type, $schemaContainer);
if (!$this->isFieldContainerSupported($containerContext)) {
continue;
}
if ($type->getModel() === $mapping['targetEntity']) {
$typeName = $type->getName();
if ($multiple) {
$typeName = sprintf('[%s]', $typeName);
}
return new TypeGuess($typeName, Guess::HIGH_CONFIDENCE);
}
}
}