mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-08 16:59:51 +00:00
Fix bug and remove obsolete issue.
This commit is contained in:
parent
5615734123
commit
a1b381a3ea
@ -45,11 +45,6 @@ parameters:
|
|||||||
count: 3
|
count: 3
|
||||||
path: src/Bundle/ChillActivityBundle/Entity/ActivityType.php
|
path: src/Bundle/ChillActivityBundle/Entity/ActivityType.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Anonymous function has an unused use \\$data\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
@ -29,27 +29,27 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|||||||
use Doctrine\ORM\Query\Expr\Join;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class ActivityTypeAggregator implements AggregatorInterface
|
class ActivityTypeAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $typeRepository;
|
protected $typeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $stringHelper;
|
protected $stringHelper;
|
||||||
|
|
||||||
const KEY = 'activity_type_aggregator';
|
const KEY = 'activity_type_aggregator';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityRepository $typeRepository,
|
EntityRepository $typeRepository,
|
||||||
TranslatableStringHelper $stringHelper
|
TranslatableStringHelper $stringHelper
|
||||||
@ -57,19 +57,19 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
$this->typeRepository = $typeRepository;
|
$this->typeRepository = $typeRepository;
|
||||||
$this->stringHelper = $stringHelper;
|
$this->stringHelper = $stringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// add select element
|
// add select element
|
||||||
$qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY));
|
$qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY));
|
||||||
|
|
||||||
// add the "group by" part
|
// add the "group by" part
|
||||||
$groupBy = $qb->addGroupBy(self::KEY);
|
$groupBy = $qb->addGroupBy(self::KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a join between Activity and another alias
|
* Check if a join between Activity and another alias
|
||||||
*
|
*
|
||||||
* @param Join[] $joins
|
* @param Join[] $joins
|
||||||
* @param string $alias the alias to search for
|
* @param string $alias the alias to search for
|
||||||
* @return boolean
|
* @return boolean
|
||||||
@ -81,7 +81,7 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,18 +99,18 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return "Aggregate by activity type";
|
return "Aggregate by activity type";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data): \Closure
|
||||||
{
|
{
|
||||||
// for performance reason, we load data from db only once
|
// for performance reason, we load data from db only once
|
||||||
$this->typeRepository->findBy(array('id' => $values));
|
$this->typeRepository->findBy(array('id' => $values));
|
||||||
|
|
||||||
return function($value) use ($data) {
|
return function($value): string {
|
||||||
if ($value === '_header') {
|
if ($value === '_header') {
|
||||||
return 'Activity type';
|
return 'Activity type';
|
||||||
}
|
}
|
||||||
@ -120,12 +120,11 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
return $this->stringHelper->localize($t->getName());
|
return $this->stringHelper->localize($t->getName());
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return array(self::KEY);
|
return [self::KEY];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user