Classes/TcaDataGenerator/FieldGenerator/TypeInlineUsecombination.php
public function generate(array $data): string
    {
        if (!isset($GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table'])) {
            throw new \RuntimeException(
                'mm child table name not found',
                1459941569
            );
        }
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
        $childChildTableName = $GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table'];
        $numberOfChildChildRowsToCreate = 4;
        $uidsOfChildrenToConnect = [];
        for ($i = 0; $i < $numberOfChildChildRowsToCreate; $i++) {
            // Insert an empty row again to have the uid already. This is useful for
            // possible further inline that may be attached to this child.
            $childFieldValues = [
                'pid' => $data['fieldValues']['pid'],
            ];
            $connection = $connectionPool->getConnectionForTable($childChildTableName);
            $connection->insert($childChildTableName, $childFieldValues);
            $childFieldValues['uid'] = $connection->lastInsertId($childChildTableName);
            if (count($uidsOfChildrenToConnect) < 2) {
                $uidsOfChildrenToConnect[] = $childFieldValues['uid'];
            }
            $recordData = GeneralUtility::makeInstance(RecordData::class);
            $childFieldValues = $recordData->generate($childChildTableName, $childFieldValues);
            $connection->update(
                $childChildTableName,
                $childFieldValues,
                [ 'uid' => (int)$childFieldValues['uid'] ]
            );
        }
        foreach ($uidsOfChildrenToConnect as $uid) {
            $mmFieldValues = [
                'pid' => $data['fieldValues']['pid'],
                'select_parent' => $data['fieldValues']['uid'],
                'select_child' => $uid,
            ];
            $tableName = $data['fieldConfig']['config']['foreign_table'];
            $connection = $connectionPool->getConnectionForTable($tableName);
            $connection->insert($tableName, $mmFieldValues);
        }
        return (string)count($uidsOfChildrenToConnect);
    }
public function generate(array $data): string
    {
        if (!isset($GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table'])) {
            throw new \RuntimeException(
                'mm child table name not found',
                1459941569
            );
        }
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
        $childChildTableName = $GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table'];
        $numberOfChildChildRowsToCreate = 4;
        $uidsOfChildrenToConnect = [];
        for ($i = 0; $i < $numberOfChildChildRowsToCreate; $i++) {
            // Insert an empty row again to have the uid already. This is useful for
            // possible further inline that may be attached to this child.
            $childFieldValues = [
                'pid' => $data['fieldValues']['pid'],
            ];
            $connection = $connectionPool->getConnectionForTable($childChildTableName);
            $connection->insert($childChildTableName, $childFieldValues);
            $childFieldValues['uid'] = $connection->lastInsertId($childChildTableName);
            if (count($uidsOfChildrenToConnect) < 2) {
                $uidsOfChildrenToConnect[] = $childFieldValues['uid'];
            }
            $recordData = GeneralUtility::makeInstance(RecordData::class);
            $childFieldValues = $recordData->generate($childChildTableName, $childFieldValues);
            $connection->update(
                $childChildTableName,
                $childFieldValues,
                [ 'uid' => (int)$childFieldValues['uid'] ]
            );
        }
        foreach ($uidsOfChildrenToConnect as $uid) {
            $mmFieldValues = [
                'pid' => $data['fieldValues']['pid'],
                'select_parent' => $data['fieldValues']['uid'],
                'select_child' => $uid,
            ];
            $tableName = $data['fieldConfig']['config']['foreign_table'];
            $connection = $connectionPool->getConnectionForTable($tableName);
            $connection->insert($tableName, $mmFieldValues);
        }
        return (string)count($uidsOfChildrenToConnect);
    }
public function generate ( array $ data ) : string { if ( ! isset ( $ GLOBALS [ 'TCA' ] [ $ data [ 'fieldConfig' ] [ 'config' ] [ 'foreign_table' ] ] [ 'columns' ] [ 'select_child' ] [ 'config' ] [ 'foreign_table' ] ) ) { throw new \ RuntimeException ( 'mm child table name not found' , 1459941569 ) ; } $ connectionPool = GeneralUtility :: makeInstance ( ConnectionPool :: class ) ; $ childChildTableName = $ GLOBALS [ 'TCA' ] [ $ data [ 'fieldConfig' ] [ 'config' ] [ 'foreign_table' ] ] [ 'columns' ] [ 'select_child' ] [ 'config' ] [ 'foreign_table' ] ; $ numberOfChildChildRowsToCreate = 4 ; $ uidsOfChildrenToConnect = [ ] ; for ( $ i = 0 ; $ i < $ numberOfChildChildRowsToCreate ; $ i ++ ) { // Insert an empty row again to have the uid already. This is useful for // possible further inline that may be attached to this child. $ childFieldValues = [ 'pid' => $ data [ 'fieldValues' ] [ 'pid' ] , ] ; $ connection = $ connectionPool -> getConnectionForTable ( $ childChildTableName ) ; $ connection -> insert ( $ childChildTableName , $ childFieldValues ) ; $ childFieldValues [ 'uid' ] = $ connection -> lastInsertId ( $ childChildTableName ) ; if ( count ( $ uidsOfChildrenToConnect ) < 2 ) { $ uidsOfChildrenToConnect [ ] = $ childFieldValues [ 'uid' ] ; } $ recordData = GeneralUtility :: makeInstance ( RecordData :: class ) ; $ childFieldValues = $ recordData -> generate ( $ childChildTableName , $ childFieldValues ) ; $ connection -> update ( $ childChildTableName , $ childFieldValues , [ 'uid' => ( int ) $ childFieldValues [ 'uid' ] ] ) ; } foreach ( $ uidsOfChildrenToConnect as $ uid ) { $ mmFieldValues = [ 'pid' => $ data [ 'fieldValues' ] [ 'pid' ] , 'select_parent' => $ data [ 'fieldValues' ] [ 'uid' ] , 'select_child' => $ uid , ] ; $ tableName = $ data [ 'fieldConfig' ] [ 'config' ] [ 'foreign_table' ] ; $ connection = $ connectionPool -> getConnectionForTable ( $ tableName ) ; $ connection -> insert ( $ tableName , $ mmFieldValues ) ; } return ( string ) count ( $ uidsOfChildrenToConnect ) ; }
Generate 4 child child rows, connect 2 of them in mm table

@param array $data
@return string
Generate 4 child child rows connect 2 of them in mm table