public function findByReservationDateAndResource(Reservation $reservation, $start, $end, Resource $resource)
 {
     $sql = "SELECT r FROM FormaLibre\\ReservationBundle\\Entity\\Reservation r\n        INNER JOIN Claroline\\AgendaBundle\\Entity\\Event e WITH r.event = e\n        WHERE ((e.start BETWEEN :start AND :end) OR (e.end BETWEEN :start AND :end) OR (e.start <= :start AND e.end >= :end))\n        AND e.start NOT IN (:start, :end)\n        AND e.end NOT IN (:start, :end)\n        AND r.resource = :resource AND r <> :reservation";
     $query = $this->_em->createQuery($sql);
     $query->setParameter('reservation', $reservation->getId());
     $query->setParameter('start', $start + 1);
     $query->setParameter('end', $end - 1);
     $query->setParameter('resource', $resource->getId());
     return $query->getResult();
 }
Ejemplo n.º 2
0
 public function checkAccess(User $user, Reservation $reservation, $mask)
 {
     if (!$this->hasAccess($user, $reservation->getResource(), $mask)) {
         throw new AccessDeniedException();
     }
 }