if ($metadata instanceof ClassMetadataInfo
) { $associationMapping =
$metadata->
getAssociationMapping($property);
if (isset($associationMapping['indexBy'
])) { /** @var ClassMetadataInfo $subMetadata */
$subMetadata =
$this->entityManager->
getClassMetadata($associationMapping['targetEntity'
]);
// Check if indexBy value is a property
$fieldName =
$associationMapping['indexBy'
];
if (null
=== ($typeOfField =
$subMetadata->
getTypeOfField($fieldName))) { $fieldName =
$subMetadata->
getFieldForColumn($associationMapping['indexBy'
]);
// Not a property, maybe a column name?
if (null
=== ($typeOfField =
$subMetadata->
getTypeOfField($fieldName))) { // Maybe the column name is the association join column?
$associationMapping =
$subMetadata->
getAssociationMapping($fieldName);
/** @var ClassMetadataInfo $subMetadata */
$indexProperty =
$subMetadata->
getSingleAssociationReferencedJoinColumnName($fieldName);
$subMetadata =
$this->entityManager->
getClassMetadata($associationMapping['targetEntity'
]);
// Not a property, maybe a column name?
if (null
=== ($typeOfField =
$subMetadata->
getTypeOfField($indexProperty))) {