/**
* Append a join to the junction table.
*
* @param \Cake\ORM\Query $query The query to append.
* @param string|array $conditions The query conditions to use.
* @return \Cake\ORM\Query The modified query.
*/
protected function _appendJunctionJoin($query, $conditions)
{
$name = $this->_junctionAssociationName();
$joins = $query->join();
$matching = [$name => ['table' => $this->junction()->table(), 'conditions' => $conditions, 'type' => 'INNER']];
$assoc = $this->target()->association($name);
$query->addDefaultTypes($assoc->target())->join($matching + $joins, [], true);
$query->eagerLoader()->addToJoinsMap($name, $assoc);
return $query;
}