private function removeDuplicateJoins(QueryBuilder $queryBuilder)
    {
        if (empty($queryBuilder->getDQLParts()['join'])) {
            return $queryBuilder;
        }
        $joinArray = [];
        $joins = $queryBuilder->getDQLParts()['join']['a'];
        foreach ($joins as $join) {
            $joinArray[] = $join->getAlias();
        }
        $joinArray = array_unique($joinArray);
        foreach ($joins as $key => $join) {
            if (!array_key_exists($key, $joinArray)) {
                unset($joins[$key]);
            }
        }

        $queryBuilder->resetDQLPart('join');
        foreach ($joins as $join) {
            $queryBuilder->join($join->getJoin(), $join->getAlias());
        }

        return $queryBuilder;
    }
private function removeDuplicateJoins(QueryBuilder $queryBuilder)
    {
        if (empty($queryBuilder->getDQLParts()['join'])) {
            return $queryBuilder;
        }
        $joinArray = [];
        $joins = $queryBuilder->getDQLParts()['join']['a'];
        foreach ($joins as $join) {
            $joinArray[] = $join->getAlias();
        }
        $joinArray = array_unique($joinArray);
        foreach ($joins as $key => $join) {
            if (!array_key_exists($key, $joinArray)) {
                unset($joins[$key]);
            }
        }

        $queryBuilder->resetDQLPart('join');
        foreach ($joins as $join) {
            $queryBuilder->join($join->getJoin(), $join->getAlias());
        }

        return $queryBuilder;
    }
private function removeDuplicateJoins ( QueryBuilder $ queryBuilder ) { if ( empty ( $ queryBuilder -> getDQLParts ( ) [ 'join' ] ) ) { return $ queryBuilder ; } $ joinArray = [ ] ; $ joins = $ queryBuilder -> getDQLParts ( ) [ 'join' ] [ 'a' ] ; foreach ( $ joins as $ join ) { $ joinArray [ ] = $ join -> getAlias ( ) ; } $ joinArray = array_unique ( $ joinArray ) ; foreach ( $ joins as $ key => $ join ) { if ( ! array_key_exists ( $ key , $ joinArray ) ) { unset ( $ joins [ $ key ] ) ; } } $ queryBuilder -> resetDQLPart ( 'join' ) ; foreach ( $ joins as $ join ) { $ queryBuilder -> join ( $ join -> getJoin ( ) , $ join -> getAlias ( ) ) ; } return $ queryBuilder ; }
Removes the duplicate joins of given query builder.

@param QueryBuilder $queryBuilder The query builder

@return QueryBuilder
Removes the duplicate joins of given query builder .