Cake\ORM\Association\BelongsToMany::_generateJunctionAssociations PHP Method

_generateJunctionAssociations() protected method

Generates the following associations: - junction belongsTo source e.g. ArticlesTags belongsTo Tags - junction belongsTo target e.g. ArticlesTags belongsTo Articles You can override these generated associations by defining associations with the correct aliases.
protected _generateJunctionAssociations ( Table $junction, Table $source, Table $target ) : void
$junction Cake\ORM\Table The junction table.
$source Cake\ORM\Table The source table.
$target Cake\ORM\Table The target table.
return void
    protected function _generateJunctionAssociations($junction, $source, $target)
    {
        $tAlias = $target->alias();
        $sAlias = $source->alias();
        if (!$junction->association($tAlias)) {
            $junction->belongsTo($tAlias, ['foreignKey' => $this->targetForeignKey(), 'targetTable' => $target]);
        }
        if (!$junction->association($sAlias)) {
            $junction->belongsTo($sAlias, ['foreignKey' => $this->foreignKey(), 'targetTable' => $source]);
        }
    }