Neos\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver::buildJoinColumnsIfNeeded PHP Method

buildJoinColumnsIfNeeded() protected method

Check if the referenced column name is set (and valid) and if not make sure it is initialized properly.
protected buildJoinColumnsIfNeeded ( array $joinColumns, array $mapping, ReflectionProperty $property, integer $direction = self::MAPPING_REGULAR ) : array
$joinColumns array
$mapping array
$property ReflectionProperty
$direction integer regular or inverse mapping (use is to be coded)
return array
    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;
    }