public function createRelationAndUpdateCounter(
        $tableName,
        $uidLocal,
        $uidForeign,
        $columnName
    ) {
        if (!$this->isTableNameAllowed($tableName)) {
            throw new \InvalidArgumentException('The table name "' . $tableName . '" is not allowed.');
        }

        if ($uidLocal <= 0) {
            throw new \InvalidArgumentException(
                '$uidLocal must be > 0, but actually is "' . $uidLocal . '"',
                1334439220
            );
        }
        if ($uidForeign <= 0) {
            throw new \InvalidArgumentException(
                '$uidForeign must be  > 0, but actually is "' . $uidForeign . '"',
                1334439233
            );
        }

        $tca = \Tx_Phpunit_Service_Database::getTcaForTable($tableName);
        $relationConfiguration = $tca['columns'][$columnName];

        if (!isset($relationConfiguration['config']['MM']) || ($relationConfiguration['config']['MM'] === '')) {
            throw new Exception(
                'The column ' . $columnName . ' in the table ' . $tableName .
                ' is not configured to contain m:n relations using a m:n table.',
                1334439257
            );
        }

        if (isset($relationConfiguration['config']['MM_opposite_field'])) {
            // Switches the order of $uidForeign and $uidLocal as the relation
            // is the reverse part of a bidirectional relation.
            $this->createRelationAndUpdateCounter(
                $relationConfiguration['config']['foreign_table'],
                $uidForeign,
                $uidLocal,
                $relationConfiguration['config']['MM_opposite_field']
            );
        } else {
            $this->createRelation(
                $relationConfiguration['config']['MM'],
                $uidLocal,
                $uidForeign
            );
        }

        $this->increaseRelationCounter($tableName, $uidLocal, $columnName);
    }
public function createRelationAndUpdateCounter(
        $tableName,
        $uidLocal,
        $uidForeign,
        $columnName
    ) {
        if (!$this->isTableNameAllowed($tableName)) {
            throw new \InvalidArgumentException('The table name "' . $tableName . '" is not allowed.');
        }

        if ($uidLocal <= 0) {
            throw new \InvalidArgumentException(
                '$uidLocal must be > 0, but actually is "' . $uidLocal . '"',
                1334439220
            );
        }
        if ($uidForeign <= 0) {
            throw new \InvalidArgumentException(
                '$uidForeign must be  > 0, but actually is "' . $uidForeign . '"',
                1334439233
            );
        }

        $tca = \Tx_Phpunit_Service_Database::getTcaForTable($tableName);
        $relationConfiguration = $tca['columns'][$columnName];

        if (!isset($relationConfiguration['config']['MM']) || ($relationConfiguration['config']['MM'] === '')) {
            throw new Exception(
                'The column ' . $columnName . ' in the table ' . $tableName .
                ' is not configured to contain m:n relations using a m:n table.',
                1334439257
            );
        }

        if (isset($relationConfiguration['config']['MM_opposite_field'])) {
            // Switches the order of $uidForeign and $uidLocal as the relation
            // is the reverse part of a bidirectional relation.
            $this->createRelationAndUpdateCounter(
                $relationConfiguration['config']['foreign_table'],
                $uidForeign,
                $uidLocal,
                $relationConfiguration['config']['MM_opposite_field']
            );
        } else {
            $this->createRelation(
                $relationConfiguration['config']['MM'],
                $uidLocal,
                $uidForeign
            );
        }

        $this->increaseRelationCounter($tableName, $uidLocal, $columnName);
    }
public function createRelationAndUpdateCounter ( $ tableName , $ uidLocal , $ uidForeign , $ columnName ) { if ( ! $ this -> isTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The table name "' . $ tableName . '" is not allowed.' ) ; } if ( $ uidLocal <= 0 ) { throw new \ InvalidArgumentException ( '$uidLocal must be > 0, but actually is "' . $ uidLocal . '"' , 1334439220 ) ; } if ( $ uidForeign <= 0 ) { throw new \ InvalidArgumentException ( '$uidForeign must be  > 0, but actually is "' . $ uidForeign . '"' , 1334439233 ) ; } $ tca = \ Tx_Phpunit_Service_Database :: getTcaForTable ( $ tableName ) ; $ relationConfiguration = $ tca [ 'columns' ] [ $ columnName ] ; if ( ! isset ( $ relationConfiguration [ 'config' ] [ 'MM' ] ) || ( $ relationConfiguration [ 'config' ] [ 'MM' ] === '' ) ) { throw new Exception ( 'The column ' . $ columnName . ' in the table ' . $ tableName . ' is not configured to contain m:n relations using a m:n table.' , 1334439257 ) ; } if ( isset ( $ relationConfiguration [ 'config' ] [ 'MM_opposite_field' ] ) ) { // Switches the order of $uidForeign and $uidLocal as the relation // is the reverse part of a bidirectional relation. $ this -> createRelationAndUpdateCounter ( $ relationConfiguration [ 'config' ] [ 'foreign_table' ] , $ uidForeign , $ uidLocal , $ relationConfiguration [ 'config' ] [ 'MM_opposite_field' ] ) ; } else { $ this -> createRelation ( $ relationConfiguration [ 'config' ] [ 'MM' ] , $ uidLocal , $ uidForeign ) ; } $ this -> increaseRelationCounter ( $ tableName , $ uidLocal , $ columnName ) ; }
Creates a relation between two records based on the rules defined in TCA
regarding the relation.

@param string $tableName
name of the table from which a relation should be created, must
not be empty
@param int $uidLocal
UID of the record in the local table, must be > 0
@param int $uidForeign
UID of the record in the foreign table, must be > 0
@param string $columnName
name of the column in which the relation counter should be
updated, must not be empty

@return void

@throws \InvalidArgumentException
@throws Exception
Creates a relation between two records based on the rules defined in TCA regarding the relation .