locationRepository = $locationRepository; } public function addRole(): ?string { return null; } public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('calloc', $qb->getAllAliases(), true)) { $qb->join('cal.location', 'calloc'); } $qb->addSelect('IDENTITY(cal.location) as location_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); if (!empty($groupBy)) { $qb->addGroupBy('location_aggregator'); } else { $qb->groupBy('location_aggregator'); } } public function applyOn(): string { return Declarations::CALENDAR_TYPE; } public function buildForm(FormBuilderInterface $builder) { // no form } public function getLabels($key, array $values, $data): Closure { return function ($value): string { if ('_header' === $value) { return 'Location'; } $l = $this->locationRepository->find($value); return $l->getName(); }; } public function getQueryKeys($data): array { return ['location_aggregator']; } public function getTitle(): string { return 'Group appointments by location'; } }