getEntityManager() ->createQuery('SELECT l.id, l.title FROM RapsysAirBundle:Session s JOIN RapsysAirBundle:Location l WHERE '.($granted?'s.application IS NOT NULL AND ':'').'l.id = s.location AND s.date BETWEEN :begin AND :end GROUP BY l.id ORDER BY l.id') ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()) ->getResult(); //Rekey array $ret = array_column($ret, 'title', 'id'); //Filter array foreach($ret as $k => $v) { $ret[$k] = $translator->trans($v); } //Send result return $ret; } }