3 namespace Rapsys\AirBundle\Repository
;
5 use Symfony\Component\Translation\TranslatorInterface
;
10 class LocationRepository
extends \Doctrine\ORM\EntityRepository
{
12 * Fetch translated location with session by date period
14 * @param $translator The TranslatorInterface instance
15 * @param $period The date period
16 * @param $granted The session is granted
18 public function fetchTranslatedLocationByDatePeriod(TranslatorInterface
$translator, $period, $granted = false) {
20 $ret = $this->getEntityManager()
21 ->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')
22 ->setParameter('begin', $period->getStartDate())
23 ->setParameter('end', $period->getEndDate())
27 $ret = array_column($ret, 'title', 'id');
30 foreach($ret as $k => $v) {
31 $ret[$k] = $translator->trans($v);