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

_generateTargetAssociations() protected method

Generates the following associations: - target hasMany junction e.g. Articles hasMany ArticlesTags - target belongsToMany source e.g Articles belongsToMany Tags. You can override these generated associations by defining associations with the correct aliases.
protected _generateTargetAssociations ( 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 _generateTargetAssociations($junction, $source, $target)
    {
        $junctionAlias = $junction->alias();
        $sAlias = $source->alias();
        if (!$target->association($junctionAlias)) {
            $target->hasMany($junctionAlias, ['targetTable' => $junction, 'foreignKey' => $this->targetForeignKey(), 'strategy' => $this->_strategy]);
        }
        if (!$target->association($sAlias)) {
            $target->belongsToMany($sAlias, ['sourceTable' => $target, 'targetTable' => $source, 'foreignKey' => $this->targetForeignKey(), 'targetForeignKey' => $this->foreignKey(), 'through' => $junction, 'conditions' => $this->conditions(), 'strategy' => $this->_strategy]);
        }
    }