diff --git a/src/Repository/NodeRepository.php b/src/Repository/NodeRepository.php index bf0dbaba..3c76eecd 100644 --- a/src/Repository/NodeRepository.php +++ b/src/Repository/NodeRepository.php @@ -376,7 +376,7 @@ public function searchByAsNodeTreeDto( $this->dispatchQueryBuilderEvent($qb, $this->getEntityName()); $this->applyFilterByCriteria($criteria, $qb); - $this->alterQueryBuilderAsNodeTreeDto($qb); + $this->alterQueryBuilderAsNodeTreeDto($qb, $alias); $query = $qb->getQuery(); $this->dispatchQueryEvent($query); @@ -384,13 +384,13 @@ public function searchByAsNodeTreeDto( return $query->getResult(); } - protected function alterQueryBuilderAsNodeTreeDto(QueryBuilder $qb): QueryBuilder + protected function alterQueryBuilderAsNodeTreeDto(QueryBuilder $qb, string $alias = self::NODE_ALIAS): QueryBuilder { - if (!$this->hasJoinedNodeType($qb, self::NODE_ALIAS)) { - $qb->innerJoin(self::NODE_ALIAS.'.nodeType', self::NODETYPE_ALIAS); + if (!$this->hasJoinedNodeType($qb, $alias)) { + $qb->innerJoin($alias.'.nodeType', self::NODETYPE_ALIAS); } - if (!$this->hasJoinedNodesSources($qb, self::NODE_ALIAS)) { - $qb->innerJoin(self::NODE_ALIAS.'.nodeSources', self::NODESSOURCES_ALIAS); + if (!$this->hasJoinedNodesSources($qb, $alias)) { + $qb->innerJoin($alias.'.nodeSources', self::NODESSOURCES_ALIAS); } $qb->select(sprintf( @@ -419,16 +419,16 @@ protected function alterQueryBuilderAsNodeTreeDto(QueryBuilder $qb): QueryBuilde ) EOT, NodeTreeDto::class, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, - self::NODE_ALIAS, + $alias, + $alias, + $alias, + $alias, + $alias, + $alias, + $alias, + $alias, + $alias, + $alias, self::NODETYPE_ALIAS, self::NODETYPE_ALIAS, self::NODETYPE_ALIAS, diff --git a/src/Repository/TagRepository.php b/src/Repository/TagRepository.php index cabdf8e1..cdaad87e 100644 --- a/src/Repository/TagRepository.php +++ b/src/Repository/TagRepository.php @@ -279,7 +279,7 @@ public function findByAsTagTreeDto( return $query->getResult(); } - protected function alterQueryBuilderAsTagTreeDto(QueryBuilder $qb): QueryBuilder + protected function alterQueryBuilderAsTagTreeDto(QueryBuilder $qb, string $alias = self::TAG_ALIAS): QueryBuilder { $qb->select(sprintf( <<