protected function _addJoin($type, $table, $fields, $on = []) {
        $repo = $this->getRepository();
        $join = new Join($type);
        $conditions = [];

        if (is_array($table)) {
            $alias = $table[1];
            $table = $table[0];
        } else {
            $alias = $table;
        }

        foreach ($on as $pfk => $rfk) {
            if (strpos($pfk, '.') === false) {
                $pfk = $repo->getAlias() . '.' . $pfk;
            }

            if (strpos($rfk, '.') === false) {
                $rfk = $alias . '.' . $rfk;
            }

            $conditions[$pfk] = $rfk;
        }

        $this->_joins[] = $join->from($table, $alias)->on($conditions)->fields($fields);

        return $this;
    }