jobRepository = $jobRepository; $this->translatableStringHelper = $translatableStringHelper; } public function getLabels($key, array $values, $data): \Closure { return function($value): string { if ($value === '_header') { return 'Job'; } $j = $this->jobRepository->find($value); return $this->translatableStringHelper->localize( $j->getLabel() ); }; } public function getQueryKeys($data): array { return ['job_aggregator']; } public function buildForm(FormBuilderInterface $builder) { // no form } public function getTitle(): string { return 'Group by agent job'; } public function addRole() { return null; } public function alterQuery(QueryBuilder $qb, $data) { $qb->join('cal.user', 'u'); $qb->addSelect('IDENTITY(u.userJob) as job_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); if (!empty($groupBy)) { $qb->addGroupBy('job_aggregator'); } else { $qb->groupBy('job_aggregator'); } } public function applyOn(): string { return Declarations::CALENDAR_TYPE; } }