protected function generateRedirectToDefaultSelection($categorySlug, $questionSlug)
    {
        $doRedirect = false;
        $config     = $this->container->getParameter('genj_faq');

        if (!$categorySlug && $config['select_first_category_by_default']) {
            $firstCategory = $this->getCategoryRepository()->retrieveFirst();
            if ($firstCategory instanceof \Genj\FaqBundle\Entity\Category) {
                $categorySlug = $firstCategory->getSlug();
                $doRedirect   = true;
            } else {
                throw $this->createNotFoundException('Tried to open the first faq category by default, but there was none.');
            }
        }

        if (!$questionSlug && $config['select_first_question_by_default']) {
            $firstQuestion = $this->getQuestionRepository()->retrieveFirstByCategorySlug($categorySlug);
            if ($firstQuestion instanceof \Genj\FaqBundle\Entity\Question) {
                $questionSlug = $firstQuestion->getSlug();
                $doRedirect   = true;
            } else {
                throw $this->createNotFoundException('Tried to open the first faq question by default, but there was none.');
            }
        }

        if ($doRedirect) {
            return $this->redirect(
                $this->generateUrl('genj_faq_faq_index', array('categorySlug' => $categorySlug, 'questionSlug' => $questionSlug), true)
            );
        }

        return false;
    }
protected function generateRedirectToDefaultSelection($categorySlug, $questionSlug)
    {
        $doRedirect = false;
        $config     = $this->container->getParameter('genj_faq');

        if (!$categorySlug && $config['select_first_category_by_default']) {
            $firstCategory = $this->getCategoryRepository()->retrieveFirst();
            if ($firstCategory instanceof \Genj\FaqBundle\Entity\Category) {
                $categorySlug = $firstCategory->getSlug();
                $doRedirect   = true;
            } else {
                throw $this->createNotFoundException('Tried to open the first faq category by default, but there was none.');
            }
        }

        if (!$questionSlug && $config['select_first_question_by_default']) {
            $firstQuestion = $this->getQuestionRepository()->retrieveFirstByCategorySlug($categorySlug);
            if ($firstQuestion instanceof \Genj\FaqBundle\Entity\Question) {
                $questionSlug = $firstQuestion->getSlug();
                $doRedirect   = true;
            } else {
                throw $this->createNotFoundException('Tried to open the first faq question by default, but there was none.');
            }
        }

        if ($doRedirect) {
            return $this->redirect(
                $this->generateUrl('genj_faq_faq_index', array('categorySlug' => $categorySlug, 'questionSlug' => $questionSlug), true)
            );
        }

        return false;
    }
protected function generateRedirectToDefaultSelection ( $ categorySlug , $ questionSlug ) { $ doRedirect = false ; $ config = $ this -> container -> getParameter ( 'genj_faq' ) ; if ( ! $ categorySlug && $ config [ 'select_first_category_by_default' ] ) { $ firstCategory = $ this -> getCategoryRepository ( ) -> retrieveFirst ( ) ; if ( $ firstCategory instanceof \ Genj \ FaqBundle \ Entity \ Category ) { $ categorySlug = $ firstCategory -> getSlug ( ) ; $ doRedirect = true ; } else { throw $ this -> createNotFoundException ( 'Tried to open the first faq category by default, but there was none.' ) ; } } if ( ! $ questionSlug && $ config [ 'select_first_question_by_default' ] ) { $ firstQuestion = $ this -> getQuestionRepository ( ) -> retrieveFirstByCategorySlug ( $ categorySlug ) ; if ( $ firstQuestion instanceof \ Genj \ FaqBundle \ Entity \ Question ) { $ questionSlug = $ firstQuestion -> getSlug ( ) ; $ doRedirect = true ; } else { throw $ this -> createNotFoundException ( 'Tried to open the first faq question by default, but there was none.' ) ; } } if ( $ doRedirect ) { return $ this -> redirect ( $ this -> generateUrl ( 'genj_faq_faq_index' , array ( 'categorySlug' => $ categorySlug , 'questionSlug' => $ questionSlug ) , true ) ) ; } return false ; }
Open first category or question if none was selected so far.

@param string $categorySlug
@param string $questionSlug

@return \Symfony\Component\HttpFoundation\RedirectResponse
@throws \Symfony\Component\HttpKernel\Exception\NotHttpException
Open first category or question if none was selected so far .