/**
  * Get distinct topic list
  *
  * @return \Acme\ModelBundle\Model\QueryBuilderHelperAbstract
  */
 private function findTopics()
 {
     $em = $this->get('doctrine.orm.entity_manager');
     $wrapper = new InterviewGetterWrapper(new InterviewGetter($em));
     $wrapper->setInput(array('fields' => 'DISTINCT( ir.topic) AS idTopic, t.id, t.name, t.slug'));
     $wrapper->setupQueryBuilder();
     return $wrapper->getRecords();
 }
 /**
  * Lists all Interview entities.
  *
  * @Route("/")
  * @Method("GET")
  * @Template()
  */
 public function indexAction()
 {
     $wrapper = new InterviewGetterWrapper(new InterviewGetter($this->getDoctrine()->getManager()));
     $wrapper->setInput(array('orderBy' => 'ir.id DESC'));
     $wrapper->setupQueryBuilder();
     $pagination = $this->get('knp_paginator')->paginate($wrapper->getObjectGetter()->getQuery(), $this->get('request')->query->get('page', 1), 8);
     $records = array();
     foreach ($pagination as $paging) {
         $records[] = $paging;
     }
     return array('pagination' => $pagination, 'entities' => $records);
 }
 /**
  * List question interview topics
  *
  * @param Request $request
  * @param $topic
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function topicListAction(Request $request, $topic)
 {
     $em = $this->get('doctrine.orm.entity_manager');
     $important = $request->get('important');
     $wrapper = new InterviewGetterWrapper(new InterviewGetter($em));
     $wrapper->setInput(array('important' => $important, 'orderBy' => 'q.position'));
     $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->getQuestion()->getId()));
         $wrapper->setupQueryBuilder();
         $tagRecords = $wrapper->getRecords();
         if (!empty($tagRecords)) {
             $paging->tags = $tagRecords;
         }
         $records[] = $paging;
     }
     return $this->render('::default/interviews/topic.html.twig', array('pagination' => $pagination, 'records' => $records, 'important' => $important, 'currentTopic' => $request->get('topic'), 'currentTag' => $request->get('tag')));
 }