mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
improve exports & add new filter, export, aggregators
This commit is contained in:
@@ -26,6 +26,7 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -76,15 +77,23 @@ class ActivityReasonAggregator implements AggregatorInterface
|
||||
}
|
||||
|
||||
$qb->addSelect($elem.' as '.$alias);
|
||||
|
||||
// make a jointure only if needed
|
||||
// add a join to reasons only if needed
|
||||
if (array_key_exists('activity', $qb->getDQLPart('join'))) {
|
||||
// we want to avoid multiple join on same object
|
||||
if (!$this->checkJoinAlreadyDefined($qb->getDQLPart('join')['activity'], 'reasons')) {
|
||||
$qb->add('join', new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons'));
|
||||
}
|
||||
} else {
|
||||
$qb->join('activity.reasons', 'reasons');
|
||||
$join = $qb->getDQLPart('join');
|
||||
if (
|
||||
(array_key_exists('activity', $join)
|
||||
&&
|
||||
!$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||
)
|
||||
OR
|
||||
(! array_key_exists('activity', $join))
|
||||
) {
|
||||
$qb->add(
|
||||
'join',
|
||||
array('activity' =>
|
||||
new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')
|
||||
),
|
||||
true);
|
||||
}
|
||||
|
||||
// join category if necessary
|
||||
@@ -178,19 +187,21 @@ class ActivityReasonAggregator implements AggregatorInterface
|
||||
|
||||
switch ($data['level']) {
|
||||
case 'reasons':
|
||||
$n = $this->reasonRepository->find($value)
|
||||
->getName()
|
||||
/* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
|
||||
$r = $this->reasonRepository->find($value);
|
||||
|
||||
return $this->stringHelper->localize($r->getCategory()->getName())
|
||||
." > "
|
||||
. $this->stringHelper->localize($r->getName());
|
||||
;
|
||||
break;
|
||||
case 'categories':
|
||||
$n = $this->categoryRepository->find($value)
|
||||
->getName()
|
||||
;
|
||||
$c = $this->categoryRepository->find($value);
|
||||
|
||||
return $this->stringHelper->localize($c->getName());
|
||||
break;
|
||||
// no need for a default : the default was already set above
|
||||
}
|
||||
|
||||
return $this->stringHelper->localize($n);
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user