Example #1
0
 /**
  * @param Question $question
  * @param int $mode
  *
  * @return string
  */
 public function voteAction(Question $question, $mode)
 {
     /** @var \HDNET\Faq\Domain\Model\Request\Vote $vote */
     $vote = $this->objectManager->get('HDNET\\Faq\\Domain\\Model\\Request\\Vote');
     $vote->setMode($mode);
     $vote->setQuestion($question);
     $result = ['state' => 'ERROR', 'description' => 'Unknown', 'currentCounter' => 0];
     $sessionIdentifier = 'topflop';
     try {
         $ids = $this->sessionService->setAndGet($sessionIdentifier, []);
         $vote->checkAgainst($ids);
         array_push($ids, $vote->getQuestion()->getUid());
         $this->sessionService->set($sessionIdentifier, $ids);
         $vote->updateQuestion();
         $this->questionRepository->update($vote->getQuestion());
         $result['state'] = 'OK';
         $result['description'] = TranslateUtility::assureLabel('eid.ok', 'hdnet_faq', 'Vielen Dank für Ihre Wertung.');
         $result['currentCounter'] = $vote->getQuestionVotes();
     } catch (AlreadyVotedException $e) {
         $result['description'] = TranslateUtility::assureLabel('eid.error.multivote', 'hdnet_faq', 'Sie haben für diese Frage bereits abgestimmt!');
     } catch (VoteException $e) {
         $result['description'] = $e->getMessage();
     }
     return json_encode($result);
 }
Example #2
0
 /**
  * Render the teaser action
  *
  * @cache 1h
  */
 public function teaserAction()
 {
     $topQuestions = GeneralUtility::intExplode(',', $this->settings['faq']['topQuestions'], true);
     $teaserCategories = GeneralUtility::intExplode(',', $this->settings['faq']['teaserCategories'], true);
     $teaserLimit = (int) $this->settings['faq']['teaserLimit'];
     $questions = $this->questionRepository->findByTeaserConfiguration($topQuestions, $teaserCategories, $teaserLimit);
     $this->view->assign('questions', $questions);
 }