/**
* Generate reciprocal associations as necessary.
*
* 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.
*
* @param \Cake\ORM\Table $junction The junction table.
* @param \Cake\ORM\Table $source The source table.
* @param \Cake\ORM\Table $target 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()]);
}
if (!$target->association($sAlias)) {
$target->belongsToMany($sAlias, ['sourceTable' => $target, 'targetTable' => $source, 'foreignKey' => $this->targetForeignKey(), 'targetForeignKey' => $this->foreignKey(), 'through' => $junction, 'conditions' => $this->conditions()]);
}
}