Classes/TcaDataGenerator/TableHandler/InlineMnSymmetric.php
public function handle(string $tableName)
    {
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);

        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $pidOfMainTable = $recordFinder->findPidOfMainTableRecord($tableName);
        $recordData = GeneralUtility::makeInstance(RecordData::class);

        $isFirst = true;
        $numberOfRelationsForFirstRecord = 2;
        $relationUids = [];
        $uidOfFirstRecord = null;
        for ($i = 0; $i < 4; $i++) {
            $fieldValues = [
                'pid' => $pidOfMainTable,
            ];
            $connection = $connectionPool->getConnectionForTable($tableName);
            $connection->insert($tableName, $fieldValues);
            $fieldValues['uid'] = $connection->lastInsertId($tableName);
            if ($isFirst) {
                $fieldValues['branches'] = $numberOfRelationsForFirstRecord;
                $uidOfFirstRecord = $fieldValues['uid'];
            }
            $fieldValues = $recordData->generate($tableName, $fieldValues);
            $connection->update(
                $tableName,
                $fieldValues,
                [ 'uid' => $fieldValues['uid'] ]
            );

            $this->generateTranslatedRecords($tableName, $fieldValues);

            if (!$isFirst && count($relationUids) < $numberOfRelationsForFirstRecord) {
                $relationUids[] = $fieldValues['uid'];
            }

            $isFirst = false;
        }

        foreach ($relationUids as $uid) {
            $mmFieldValues = [
                'pid' => $pidOfMainTable,
                'hotelid' => $uidOfFirstRecord,
                'branchid' => $uid,
            ];
            $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mnsymmetric_mm');
            $connection->insert(
                'tx_styleguide_inline_mnsymmetric_mm',
                $mmFieldValues
            );
        }
    }
public function handle(string $tableName)
    {
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);

        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $pidOfMainTable = $recordFinder->findPidOfMainTableRecord($tableName);
        $recordData = GeneralUtility::makeInstance(RecordData::class);

        $isFirst = true;
        $numberOfRelationsForFirstRecord = 2;
        $relationUids = [];
        $uidOfFirstRecord = null;
        for ($i = 0; $i < 4; $i++) {
            $fieldValues = [
                'pid' => $pidOfMainTable,
            ];
            $connection = $connectionPool->getConnectionForTable($tableName);
            $connection->insert($tableName, $fieldValues);
            $fieldValues['uid'] = $connection->lastInsertId($tableName);
            if ($isFirst) {
                $fieldValues['branches'] = $numberOfRelationsForFirstRecord;
                $uidOfFirstRecord = $fieldValues['uid'];
            }
            $fieldValues = $recordData->generate($tableName, $fieldValues);
            $connection->update(
                $tableName,
                $fieldValues,
                [ 'uid' => $fieldValues['uid'] ]
            );

            $this->generateTranslatedRecords($tableName, $fieldValues);

            if (!$isFirst && count($relationUids) < $numberOfRelationsForFirstRecord) {
                $relationUids[] = $fieldValues['uid'];
            }

            $isFirst = false;
        }

        foreach ($relationUids as $uid) {
            $mmFieldValues = [
                'pid' => $pidOfMainTable,
                'hotelid' => $uidOfFirstRecord,
                'branchid' => $uid,
            ];
            $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mnsymmetric_mm');
            $connection->insert(
                'tx_styleguide_inline_mnsymmetric_mm',
                $mmFieldValues
            );
        }
    }
public function handle ( string $ tableName ) { $ connectionPool = GeneralUtility :: makeInstance ( ConnectionPool :: class ) ; $ recordFinder = GeneralUtility :: makeInstance ( RecordFinder :: class ) ; $ pidOfMainTable = $ recordFinder -> findPidOfMainTableRecord ( $ tableName ) ; $ recordData = GeneralUtility :: makeInstance ( RecordData :: class ) ; $ isFirst = true ; $ numberOfRelationsForFirstRecord = 2 ; $ relationUids = [ ] ; $ uidOfFirstRecord = null ; for ( $ i = 0 ; $ i < 4 ; $ i ++ ) { $ fieldValues = [ 'pid' => $ pidOfMainTable , ] ; $ connection = $ connectionPool -> getConnectionForTable ( $ tableName ) ; $ connection -> insert ( $ tableName , $ fieldValues ) ; $ fieldValues [ 'uid' ] = $ connection -> lastInsertId ( $ tableName ) ; if ( $ isFirst ) { $ fieldValues [ 'branches' ] = $ numberOfRelationsForFirstRecord ; $ uidOfFirstRecord = $ fieldValues [ 'uid' ] ; } $ fieldValues = $ recordData -> generate ( $ tableName , $ fieldValues ) ; $ connection -> update ( $ tableName , $ fieldValues , [ 'uid' => $ fieldValues [ 'uid' ] ] ) ; $ this -> generateTranslatedRecords ( $ tableName , $ fieldValues ) ; if ( ! $ isFirst && count ( $ relationUids ) < $ numberOfRelationsForFirstRecord ) { $ relationUids [ ] = $ fieldValues [ 'uid' ] ; } $ isFirst = false ; } foreach ( $ relationUids as $ uid ) { $ mmFieldValues = [ 'pid' => $ pidOfMainTable , 'hotelid' => $ uidOfFirstRecord , 'branchid' => $ uid , ] ; $ connection = $ connectionPool -> getConnectionForTable ( 'tx_styleguide_inline_mnsymmetric_mm' ) ; $ connection -> insert ( 'tx_styleguide_inline_mnsymmetric_mm' , $ mmFieldValues ) ; } }
Create 4 rows, add row 2 and 3 as branch to row 1

@param string $tableName
@return string
Create 4 rows add row 2 and 3 as branch to row 1