/**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $em = $this->get('doctrine.orm.entity_manager');
     $topicsGetterWrapper = new TopicsGetterWrapper(new QuizQuestionsTopicsGetter($em));
     $topicsGetterWrapper->setupQueryBuilder();
     $topicsGetterWrapper->setInput(array());
     $quizTagsGetterWrapper = new QuizTagsGetterWrapper(new QuizTagsGetter($em));
     $quizTagsGetterWrapper->setInput(array('fields' => 'DISTINCT(qt.id) AS id, qt.name'));
     $quizTagsGetterWrapper->setupQueryBuilder();
     $topicsTreeSetup = new TopicsTreeSetup();
     $topicsTreeSetup->setTopicsGetterWrapper(new TopicsGetterWrapper(new TopicsGetter($em)));
     $topicsTreeSetup->setupTopicsFromDb(array());
     $topicsTreeSetup->setupRecordsTree();
     $interviewTopicsGetter = new TopicsGetterWrapper(new InterviewTopicsGetter($em));
     $interviewTopicsGetter->setupQueryBuilder();
     $interviewTopicsGetter->setInput(array());
     $interviewTagsGetterWrapper = new InterviewTagsGetterWrapper(new InterviewTagsGetter($em));
     $interviewTagsGetterWrapper->setInput(array('fields' => 'DISTINCT(t.id) AS tagId, t.name, t.slug'));
     $interviewTagsGetterWrapper->setupQueryBuilder();
     return $this->render('::default/index.html.twig', array('quizTopicsRecords' => $topicsGetterWrapper->getRecords(), 'quizTags' => $quizTagsGetterWrapper->getRecords(), 'interviewTopics' => $interviewTopicsGetter->getRecords(), 'interviewTags' => $interviewTagsGetterWrapper->getRecords(), 'topicsTree' => $topicsTreeSetup->getRecordsTree()));
 }
 /**
  * From a tag slug, select related interview questions
  *
  * @param Request $request
  * @param string $tag
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function tagListAction(Request $request, $tag)
 {
     $em = $this->get('doctrine.orm.entity_manager');
     $important = $request->get('important');
     $wrapper = new InterviewTagsGetterWrapper(new InterviewTagsGetter($em));
     $wrapper->setInput(array('fields' => 'DISTINCT(q.id) AS questionId, q.question, q.answer', 'tagSlug' => $tag, 'important' => $important));
     $wrapper->setupQueryBuilder();
     /** @var \Knp\Component\Pager\Paginator $pagination */
     $pagination = $this->get('knp_paginator')->paginate($wrapper->getObjectGetter()->getQuery(), $this->get('request')->query->get('page', 1), 12);
     $records = array();
     foreach ($pagination as $paging) {
         $wrapper = new InterviewTagsGetterWrapper(new InterviewTagsGetter($em));
         $wrapper->setInput(array('fields' => 'DISTINCT(t.id) AS tagId, t.name, t.slug', 'questionId' => $paging['questionId']));
         $wrapper->setupQueryBuilder();
         $tagRecords = $wrapper->getRecords();
         if (!empty($tagRecords)) {
             $paging['tags'] = $tagRecords;
         }
         $records[] = $paging;
     }
     return $this->render('::default/interviews/tag.html.twig', array('pagination' => $pagination, 'records' => $records, 'important' => $important, 'currentTag' => $tag));
 }