Esempio n. 1
0
 /**
  * Get latest comments
  *
  * @param Poll $poll
  * @return \Doctrine\Common\Collections\Collection
  */
 public function getLatestComments(Poll $poll)
 {
     $query = $this->getEntityManager()->createQuery("SELECT comment\n            FROM KyelaBundle:Comment comment\n            WHERE comment.poll = :poll\n            ORDER BY comment.datetime DESC");
     $query->setParameter('poll', $poll->getId());
     $query->setMaxResults(6);
     return $query->getResult();
 }
Esempio n. 2
0
 /**
  * Get future or past events
  *
  * @param Poll $poll
  * @param Boolean $isFuture
  * @return Event[]
  */
 public function getFutureOrPastEvents(Poll $poll, $isFuture = true)
 {
     $sign = $isFuture ? ">=" : "<";
     $query = $this->getEntityManager()->createQuery("SELECT event\n            FROM KyelaBundle:Event event\n            WHERE event.poll = :poll\n                AND (event.date {$sign} :date OR event.date IS NULL)\n            ORDER BY event.date, event.time");
     $query->setParameter('poll', $poll->getId());
     $query->setParameter('date', new \DateTime("today"));
     return $query->getResult();
 }
Esempio n. 3
0
 /**
  * Get future events
  */
 public function getOrderedChoices(Poll $poll)
 {
     $query = $this->getEntityManager()->createQuery('SELECT choice
         FROM KyelaBundle:Choice choice
         WHERE choice.poll = :poll
         ORDER BY choice.priority');
     $query->setParameter('poll', $poll->getId());
     return $query->getResult();
 }