public function withParentIdAs(string $columnName)
    {
        call_user_func($this->callback, function ($idString, Table $parentTable) use ($columnName) {
            /** @var IEntityMapper $mapper */
            $mapper = call_user_func($this->mapperLoader);
            $mapper->addForeignKey(ForeignKey::createWithNamingConvention(
                $mapper->getPrimaryTableName(),
                [$columnName],
                $parentTable->getName(),
                [$parentTable->getPrimaryKeyColumnName()],
                $this->identifying
                    ? ForeignKeyMode::CASCADE
                    : ForeignKeyMode::SET_NULL,
                ForeignKeyMode::CASCADE
            ));

            if ($this->orderPersistColumn) {
                $persistHook = new OrderIndexPropertyLoaderHook(
                    $mapper->getObjectType(),
                    $mapper->getPrimaryTable(),
                    $this->orderPersistColumn,
                    $columnName,
                    $mapper->getDefinition()->getPropertyLinkedToColumn($this->orderPersistColumn)
                );

                $mapper->addPersistHook($persistHook);
                $persistHookId = $persistHook->getIdString();
            } else {
                $persistHookId = null;
            }

            return new ToManyRelation(
                $idString,
                $this->loadIds
                    ? new ToManyRelationIdentityReference($mapper, $this->bidirectionalRelationProperty)
                    : new ToManyRelationObjectReference($mapper, $this->bidirectionalRelationProperty, $persistHookId),
                $columnName,
                $this->identifying
                    ? new IdentifyingRelationMode()
                    : new NonIdentifyingRelationMode(),
                $this->orderByColumnNameDirectionMap,
                $this->orderPersistColumn
            );
        });
    }
public function withParentIdAs(string $columnName)
    {
        call_user_func($this->callback, function ($idString, Table $parentTable) use ($columnName) {
            /** @var IEntityMapper $mapper */
            $mapper = call_user_func($this->mapperLoader);
            $mapper->addForeignKey(ForeignKey::createWithNamingConvention(
                $mapper->getPrimaryTableName(),
                [$columnName],
                $parentTable->getName(),
                [$parentTable->getPrimaryKeyColumnName()],
                $this->identifying
                    ? ForeignKeyMode::CASCADE
                    : ForeignKeyMode::SET_NULL,
                ForeignKeyMode::CASCADE
            ));

            if ($this->orderPersistColumn) {
                $persistHook = new OrderIndexPropertyLoaderHook(
                    $mapper->getObjectType(),
                    $mapper->getPrimaryTable(),
                    $this->orderPersistColumn,
                    $columnName,
                    $mapper->getDefinition()->getPropertyLinkedToColumn($this->orderPersistColumn)
                );

                $mapper->addPersistHook($persistHook);
                $persistHookId = $persistHook->getIdString();
            } else {
                $persistHookId = null;
            }

            return new ToManyRelation(
                $idString,
                $this->loadIds
                    ? new ToManyRelationIdentityReference($mapper, $this->bidirectionalRelationProperty)
                    : new ToManyRelationObjectReference($mapper, $this->bidirectionalRelationProperty, $persistHookId),
                $columnName,
                $this->identifying
                    ? new IdentifyingRelationMode()
                    : new NonIdentifyingRelationMode(),
                $this->orderByColumnNameDirectionMap,
                $this->orderPersistColumn
            );
        });
    }
public function withParentIdAs ( string $ columnName ) { call_user_func ( $ this -> callback , function ( $ idString , Table $ parentTable ) use ( $ columnName ) { /** @var IEntityMapper $mapper */ $ mapper = call_user_func ( $ this -> mapperLoader ) ; $ mapper -> addForeignKey ( ForeignKey :: createWithNamingConvention ( $ mapper -> getPrimaryTableName ( ) , [ $ columnName ] , $ parentTable -> getName ( ) , [ $ parentTable -> getPrimaryKeyColumnName ( ) ] , $ this -> identifying ? ForeignKeyMode :: CASCADE : ForeignKeyMode :: SET_NULL , ForeignKeyMode :: CASCADE ) ) ; if ( $ this -> orderPersistColumn ) { $ persistHook = new OrderIndexPropertyLoaderHook ( $ mapper -> getObjectType ( ) , $ mapper -> getPrimaryTable ( ) , $ this -> orderPersistColumn , $ columnName , $ mapper -> getDefinition ( ) -> getPropertyLinkedToColumn ( $ this -> orderPersistColumn ) ) ; $ mapper -> addPersistHook ( $ persistHook ) ; $ persistHookId = $ persistHook -> getIdString ( ) ; } else { $ persistHookId = null ; } return new ToManyRelation ( $ idString , $ this -> loadIds ? new ToManyRelationIdentityReference ( $ mapper , $ this -> bidirectionalRelationProperty ) : new ToManyRelationObjectReference ( $ mapper , $ this -> bidirectionalRelationProperty , $ persistHookId ) , $ columnName , $ this -> identifying ? new IdentifyingRelationMode ( ) : new NonIdentifyingRelationMode ( ) , $ this -> orderByColumnNameDirectionMap , $ this -> orderPersistColumn ) ; } ) ; }
Defines the relationship as one-to-many mapping the parent
id to the supplied column.

@param string $columnName

@return void
Defines the relationship as one - to - many mapping the parent id to the supplied column .