original_string: public function showAction(Request $request, $slug)
      {
          $query  = trim(strtolower(strip_tags($request->get('query', ''))));
          $search = null;
  
          // if we have a slug - there was a search before
          if ($slug) {
              /** @var \Genj\FaqBundle\Entity\Search $search */
              $search = $this->getSearchRepository()->findOneBySlug($slug);
          }
  
          // just without slug the query is interesting
          elseif ($query != '') {
  
              // is my query a plain number?
              // than redirect there right away
              /** @var \Genj\FaqBundle\Entity\Question $question */
              $question = $this->getQuestionRepository()->findOneById($query);
  
              if ($question) {
                  return $this->redirectToRoute($question->getRouteName(), $question->getRouteParameters());
              }
  
              /** @var \Genj\FaqBundle\Entity\Search $search */
              $search = $this->getSearchRepository()->findOneByHeadline($query);
          }
  
          // and if we don't have anything yet - we start from scratch
          if (!$search and $query != '') {
              /** @var \Genj\FaqBundle\Entity\Search $search */
              $className = $this->getSearchRepository()->getClassName();
              $search    = new $className();
              $search->setHeadline($query);
          }
  
          // increase search count
          if ($search) {
              $search->setSearchCount($search->getSearchCount() + 1);
  
              /** @var EntityManager $em */
              $em = $this->getDoctrine()->getManager();
              $em->persist($search);
              $em->flush();
          }
  
          return $this->render(
              'GenjFaqBundle:Search:show.html.twig',
              array(
                  'query'  => $query,
                  'search' => $search
              )
          );
      }
code: public function showAction(Request $request, $slug)
      {
          $query  = trim(strtolower(strip_tags($request->get('query', ''))));
          $search = null;
  
          // if we have a slug - there was a search before
          if ($slug) {
              /** @var \Genj\FaqBundle\Entity\Search $search */
              $search = $this->getSearchRepository()->findOneBySlug($slug);
          }
  
          // just without slug the query is interesting
          elseif ($query != '') {
  
              // is my query a plain number?
              // than redirect there right away
              /** @var \Genj\FaqBundle\Entity\Question $question */
              $question = $this->getQuestionRepository()->findOneById($query);
  
              if ($question) {
                  return $this->redirectToRoute($question->getRouteName(), $question->getRouteParameters());
              }
  
              /** @var \Genj\FaqBundle\Entity\Search $search */
              $search = $this->getSearchRepository()->findOneByHeadline($query);
          }
  
          // and if we don't have anything yet - we start from scratch
          if (!$search and $query != '') {
              /** @var \Genj\FaqBundle\Entity\Search $search */
              $className = $this->getSearchRepository()->getClassName();
              $search    = new $className();
              $search->setHeadline($query);
          }
  
          // increase search count
          if ($search) {
              $search->setSearchCount($search->getSearchCount() + 1);
  
              /** @var EntityManager $em */
              $em = $this->getDoctrine()->getManager();
              $em->persist($search);
              $em->flush();
          }
  
          return $this->render(
              'GenjFaqBundle:Search:show.html.twig',
              array(
                  'query'  => $query,
                  'search' => $search
              )
          );
      }
code_tokens: public function showAction ( Request $ request , $ slug ) { $ query = trim ( strtolower ( strip_tags ( $ request -> get ( 'query' , '' ) ) ) ) ; $ search = null ; // if we have a slug - there was a search before if ( $ slug ) { /** @var \Genj\FaqBundle\Entity\Search $search */ $ search = $ this -> getSearchRepository ( ) -> findOneBySlug ( $ slug ) ; } // just without slug the query is interesting elseif ( $ query != '' ) { // is my query a plain number? // than redirect there right away /** @var \Genj\FaqBundle\Entity\Question $question */ $ question = $ this -> getQuestionRepository ( ) -> findOneById ( $ query ) ; if ( $ question ) { return $ this -> redirectToRoute ( $ question -> getRouteName ( ) , $ question -> getRouteParameters ( ) ) ; } /** @var \Genj\FaqBundle\Entity\Search $search */ $ search = $ this -> getSearchRepository ( ) -> findOneByHeadline ( $ query ) ; } // and if we don't have anything yet - we start from scratch if ( ! $ search and $ query != '' ) { /** @var \Genj\FaqBundle\Entity\Search $search */ $ className = $ this -> getSearchRepository ( ) -> getClassName ( ) ; $ search = new $ className ( ) ; $ search -> setHeadline ( $ query ) ; } // increase search count if ( $ search ) { $ search -> setSearchCount ( $ search -> getSearchCount ( ) + 1 ) ; /** @var EntityManager $em */ $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ search ) ; $ em -> flush ( ) ; } return $ this -> render ( 'GenjFaqBundle:Search:show.html.twig' , array ( 'query' => $ query , 'search' => $ search ) ) ; }
docstring: shows search results for previous queries
  
  @param Request $request
  @param string  $slug
  
  @return \Symfony\Component\HttpFoundation\Response
docstring_tokens: shows search results for previous queries