exports: simplify with querybuilder method to getRootAlias

This commit is contained in:
2022-08-11 11:58:54 +02:00
parent 70488a935d
commit 6e467a62d4
4 changed files with 5 additions and 38 deletions

View File

@@ -80,7 +80,7 @@ final class JobAggregator implements AggregatorInterface
*/
public function alterQuery(QueryBuilder $qb, $data)
{
switch ($this->getBaseEntityAppliedOn($qb)) {
switch ($qb->getRootAlias()) {
case 'acp':
$qb->join('acp.job', 'j');
@@ -112,12 +112,4 @@ final class JobAggregator implements AggregatorInterface
{
return Declarations::ACP_SHARED;
}
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
{
/** @var From $from */
$from = $qb->getDQLPart('from');
return $from[0]->getAlias();
}
}

View File

@@ -40,7 +40,7 @@ final class ReferrerAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
switch ($this->getBaseEntityAppliedOn($qb)) {
switch ($qb->getRootAlias()) {
case 'acp':
$qb->join('acp.user', 'u');
@@ -98,12 +98,4 @@ final class ReferrerAggregator implements AggregatorInterface
{
return 'Group by referrers';
}
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
{
/** @var From $from */
$from = $qb->getDQLPart('from');
return $from[0]->getAlias();
}
}

View File

@@ -80,7 +80,7 @@ final class ScopeAggregator implements AggregatorInterface
*/
public function alterQuery(QueryBuilder $qb, $data)
{
switch ($this->getBaseEntityAppliedOn($qb)) {
switch ($qb->getRootAlias()) {
case 'acp':
$qb->join('acp.scopes', 's');
@@ -112,12 +112,4 @@ final class ScopeAggregator implements AggregatorInterface
{
return Declarations::ACP_SHARED;
}
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
{
/** @var From $from */
$from = $qb->getDQLPart('from');
return $from[0]->getAlias();
}
}