mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +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)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
switch ($qb->getRootAlias()) {
|
||||||
|
|
||||||
case 'acp':
|
case 'acp':
|
||||||
$qb->join('acp.job', 'j');
|
$qb->join('acp.job', 'j');
|
||||||
@ -112,12 +112,4 @@ final class JobAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return Declarations::ACP_SHARED;
|
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)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
switch ($qb->getRootAlias()) {
|
||||||
|
|
||||||
case 'acp':
|
case 'acp':
|
||||||
$qb->join('acp.user', 'u');
|
$qb->join('acp.user', 'u');
|
||||||
@ -98,12 +98,4 @@ final class ReferrerAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return 'Group by referrers';
|
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)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
switch ($qb->getRootAlias()) {
|
||||||
|
|
||||||
case 'acp':
|
case 'acp':
|
||||||
$qb->join('acp.scopes', 's');
|
$qb->join('acp.scopes', 's');
|
||||||
@ -112,12 +112,4 @@ final class ScopeAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return Declarations::ACP_SHARED;
|
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)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
// Use querybuilder from alias to find which export context (indicator)
|
switch ($qb->getRootAlias()) {
|
||||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
|
||||||
case 'acp':
|
case 'acp':
|
||||||
$clause = $qb->expr()->in('acp.user', ':referrers');
|
$clause = $qb->expr()->in('acp.user', ':referrers');
|
||||||
break;
|
break;
|
||||||
@ -103,14 +102,6 @@ class ReferrerFilter implements FilterInterface
|
|||||||
$qb->setParameter('referrers', $data['accepted_referrers']);
|
$qb->setParameter('referrers', $data['accepted_referrers']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
|
|
||||||
{
|
|
||||||
/** @var From $from */
|
|
||||||
$from = $qb->getDQLPart('from');
|
|
||||||
|
|
||||||
return $from[0]->getAlias();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user