mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: simplify with querybuilder method to getRootAlias
This commit is contained in:
parent
70488a935d
commit
6e467a62d4
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -75,11 +75,10 @@ class ReferrerFilter implements FilterInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
// Use querybuilder from alias to find which export context (indicator)
|
||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
||||
switch ($qb->getRootAlias()) {
|
||||
|
||||
case 'acp':
|
||||
$clause = $qb->expr()->in('acp.user', ':referrers');
|
||||
break;
|
||||
@ -103,14 +102,6 @@ class ReferrerFilter implements FilterInterface
|
||||
$qb->setParameter('referrers', $data['accepted_referrers']);
|
||||
}
|
||||
|
||||
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
|
||||
{
|
||||
/** @var From $from */
|
||||
$from = $qb->getDQLPart('from');
|
||||
|
||||
return $from[0]->getAlias();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user