コード例 #1
0
ファイル: CommentRepository.php プロジェクト: abienvenu/kyela
 /**
  * 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();
 }
コード例 #2
0
ファイル: EventRepository.php プロジェクト: abienvenu/kyela
 /**
  * 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();
 }
コード例 #3
0
ファイル: ChoiceRepository.php プロジェクト: abienvenu/kyela
 /**
  * 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();
 }
コード例 #4
0
ファイル: PollController.php プロジェクト: abienvenu/kyela
 /**
  * Displays a form to create a new Poll entity.
  *
  * @Route("/", name="poll_new")
  * @Method({"GET", "POST"})
  * @Template()
  */
 public function newAction(Request $request)
 {
     $poll = new Poll();
     // Setup default (and hidden) values
     $poll->setUrl(uniqid());
     $poll->setHeadLines('');
     $poll->setBottomLines('');
     $poll->setAccessCode('');
     $t = $this->get('translator');
     $poll->addChoice((new Choice())->setName($t->trans('yes'))->setValue(1)->setColor('green')->setPriority(0)->setPoll($poll)->setIcon('ok'));
     $poll->addChoice((new Choice())->setName($t->trans('maybe'))->setValue(0)->setColor('orange')->setPriority(1)->setPoll($poll)->setIcon('time'));
     $poll->addChoice((new Choice())->setName($t->trans('no'))->setValue(0)->setColor('red')->setPriority(2)->setPoll($poll)->setIcon('remove'));
     $baseUrl = $this->generateUrl('poll_show', ['pollUrl' => $poll->getUrl()], true);
     $successMessage = $this->get('translator')->trans('poll.created %url%', ['%url%' => $baseUrl]);
     return $this->doNewAction(NewPollType::class, $poll, $request, $successMessage);
 }