protected function buildJoinColumnsIfNeeded(array $joinColumns, array $mapping, \ReflectionProperty $property, $direction = self::MAPPING_REGULAR)
{
if ($joinColumns === []) {
$joinColumns[] = ['name' => strtolower($property->getName()), 'referencedColumnName' => null];
}
foreach ($joinColumns as &$joinColumn) {
if ($joinColumn['referencedColumnName'] === null || $joinColumn['referencedColumnName'] === 'id') {
if ($direction === self::MAPPING_REGULAR) {
$idProperties = $this->reflectionService->getPropertyNamesByTag($mapping['targetEntity'], 'id');
$joinColumnName = $this->buildJoinTableColumnName($mapping['targetEntity']);
} else {
$className = $this->getUnproxiedClassName($property->getDeclaringClass()->getName());
$idProperties = $this->reflectionService->getPropertyNamesByTag($className, 'id');
$joinColumnName = $this->buildJoinTableColumnName($className);
}
if (count($idProperties) === 0) {
$joinColumn['name'] = $joinColumn['name'] === null ? $joinColumnName : $joinColumn['name'];
$joinColumn['referencedColumnName'] = strtolower('Persistence_Object_Identifier');
} elseif (count($idProperties) === 1) {
$joinColumn['name'] = $joinColumn['name'] === null ? $joinColumnName : $joinColumn['name'];
$joinColumn['referencedColumnName'] = strtolower(current($idProperties));
}
}
}
return $joinColumns;
}