parent
							
								
									f2b46bb449
								
							
						
					
					
						commit
						136793be5c
					
				@ -1,22 +1,21 @@ | 
				
			||||
# see https://github.com/phiamo/MopaBootstrapBundle/blob/master/Resources/doc/misc/configuration-reference.md | 
				
			||||
#mopa_bootstrap: | 
				
			||||
#    # Adds twig form theme  support | 
				
			||||
##        horizontal_label_class: 'aa' | 
				
			||||
##        horizontal_input_wrapper_class: 'dd' | 
				
			||||
#    menu: ~  # enables twig helpers for menu | 
				
			||||
#    form: | 
				
			||||
#          show_legend: true # default is true | 
				
			||||
#          show_child_legend: false # default is true | 
				
			||||
#          error_type: block # or inline which is default | 
				
			||||
#          render_optional_text: true | 
				
			||||
# | 
				
			||||
#          collection: | 
				
			||||
#              widget_remove_btn: | 
				
			||||
#                  icon: trash | 
				
			||||
#                  icon_color: white | 
				
			||||
#                  attr: | 
				
			||||
#                      class: btn btn-danger | 
				
			||||
#              widget_add_btn: | 
				
			||||
#                  icon: plus-sign | 
				
			||||
#                  attr: | 
				
			||||
#                      class: btn btn-primary | 
				
			||||
mopa_bootstrap: | 
				
			||||
    # Adds twig form theme  support | 
				
			||||
#        horizontal_label_class: 'aa' | 
				
			||||
#        horizontal_input_wrapper_class: 'dd' | 
				
			||||
    menu: ~  # enables twig helpers for menu | 
				
			||||
    form: | 
				
			||||
          show_legend: true # default is true | 
				
			||||
          show_child_legend: false # default is true | 
				
			||||
          error_type: block # or inline which is default | 
				
			||||
          render_optional_text: true | 
				
			||||
 | 
				
			||||
          collection: | 
				
			||||
              widget_remove_btn: | 
				
			||||
                  icon: trash | 
				
			||||
                  attr: | 
				
			||||
                      class: btn btn-danger | 
				
			||||
              widget_add_btn: | 
				
			||||
                  icon: plus-sign | 
				
			||||
                  attr: | 
				
			||||
                      class: btn btn-primary | 
				
			||||
 | 
				
			||||
@ -0,0 +1,6 @@ | 
				
			||||
sonata_translation: | 
				
			||||
    locales: [en, fr, it, nl, es] | 
				
			||||
    default_locale: en | 
				
			||||
    # here enable the types you need | 
				
			||||
    gedmo: | 
				
			||||
        enabled: true | 
				
			||||
@ -0,0 +1,68 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Admin; | 
				
			||||
 | 
				
			||||
use Sonata\AdminBundle\Admin\Admin; | 
				
			||||
use Sonata\AdminBundle\Datagrid\ListMapper; | 
				
			||||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | 
				
			||||
use Sonata\AdminBundle\Form\FormMapper; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class QuestionAdmin | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqAdminBundle\Admin | 
				
			||||
 */ | 
				
			||||
class CategoryAdmin extends Admin | 
				
			||||
{ | 
				
			||||
    protected $datagridValues = array( | 
				
			||||
        '_page' => 1, | 
				
			||||
        '_sort_by' => 'created_at', | 
				
			||||
        '_sort_order' => 'Desc' | 
				
			||||
    ); | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param DatagridMapper $datagridMapper | 
				
			||||
     */ | 
				
			||||
    protected function configureDatagridFilters(DatagridMapper $datagridMapper) | 
				
			||||
    { | 
				
			||||
        $datagridMapper | 
				
			||||
            ->add('headline') | 
				
			||||
            ->add('body') | 
				
			||||
            ->add('rank') | 
				
			||||
            ->add('isActive') | 
				
			||||
        ; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param ListMapper $listMapper | 
				
			||||
     */ | 
				
			||||
    protected function configureListFields(ListMapper $listMapper) | 
				
			||||
    { | 
				
			||||
        $listMapper | 
				
			||||
            ->add('headline', null, array('identifier' => true)) | 
				
			||||
            ->add('_action', 'actions', | 
				
			||||
                array( | 
				
			||||
                    'actions' => array( | 
				
			||||
                        'show' => array(), | 
				
			||||
                        'edit' => array(), | 
				
			||||
                        'delete' => array() | 
				
			||||
                    ) | 
				
			||||
                ) | 
				
			||||
            ) | 
				
			||||
        ; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param FormMapper $formMapper | 
				
			||||
     */ | 
				
			||||
    protected function configureFormFields(FormMapper $formMapper) | 
				
			||||
    { | 
				
			||||
        $formMapper | 
				
			||||
            ->add('headline', null, array('attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('body', null, array('required' => false, 'attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('rank', null, array('required' => false, 'attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('slug') | 
				
			||||
            ->add('isActive') | 
				
			||||
            ->end(); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,74 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Admin; | 
				
			||||
 | 
				
			||||
use Sonata\AdminBundle\Admin\Admin; | 
				
			||||
use Sonata\AdminBundle\Datagrid\ListMapper; | 
				
			||||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | 
				
			||||
use Sonata\AdminBundle\Form\FormMapper; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class QuestionAdmin | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqAdminBundle\Admin | 
				
			||||
 */ | 
				
			||||
class QuestionAdmin extends Admin | 
				
			||||
{ | 
				
			||||
    protected $datagridValues = array( | 
				
			||||
        '_page' => 1, | 
				
			||||
        '_sort_by' => 'issueDate', | 
				
			||||
        '_sort_order' => 'Desc' | 
				
			||||
    ); | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param DatagridMapper $datagridMapper | 
				
			||||
     */ | 
				
			||||
    protected function configureDatagridFilters(DatagridMapper $datagridMapper) | 
				
			||||
    { | 
				
			||||
        $datagridMapper | 
				
			||||
            ->add('headline') | 
				
			||||
            ->add('body') | 
				
			||||
            ->add('category') | 
				
			||||
            ->add('slug'); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param ListMapper $listMapper | 
				
			||||
     */ | 
				
			||||
    protected function configureListFields(ListMapper $listMapper) | 
				
			||||
    { | 
				
			||||
        $listMapper | 
				
			||||
            ->addIdentifier('id') | 
				
			||||
            ->add('headline', null, array('identifier' => true)) | 
				
			||||
            ->add('Category') | 
				
			||||
            ->add('rank') | 
				
			||||
            ->add('_action', 'actions', | 
				
			||||
                array( | 
				
			||||
                    'actions' => array( | 
				
			||||
                        'show' => array(), | 
				
			||||
                        'edit' => array(), | 
				
			||||
                        'delete' => array() | 
				
			||||
                    ) | 
				
			||||
                ) | 
				
			||||
            ); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param FormMapper $formMapper | 
				
			||||
     */ | 
				
			||||
    protected function configureFormFields(FormMapper $formMapper) | 
				
			||||
    { | 
				
			||||
        $formMapper | 
				
			||||
            ->add('headline', null, array('attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('body', null, array('required' => false, 'attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('category', null, array( | 
				
			||||
                    'expanded' => true, | 
				
			||||
                    'required' => true, | 
				
			||||
                    'attr' => array('class' => 'radio-list vertical') | 
				
			||||
                )) | 
				
			||||
            ->add('rank', null, array('required' => false, 'attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('slug', null, array('required' => false, 'attr' => array('class' => 'span12'))) | 
				
			||||
            ->add('onlyAuthUsers') | 
				
			||||
            ->end(); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,18 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle; | 
				
			||||
 | 
				
			||||
use Symfony\Component\HttpKernel\Bundle\Bundle; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class ChamiloFaqBundle | 
				
			||||
 * | 
				
			||||
 * Based in GenjFaqBundle | 
				
			||||
 *  | 
				
			||||
 * @package Chamilo\UserBundle | 
				
			||||
 */ | 
				
			||||
class ChamiloFaqBundle extends Bundle | 
				
			||||
{ | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -0,0 +1,183 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Controller; | 
				
			||||
 | 
				
			||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 
				
			||||
use Chamilo\FaqBundle\Entity\Category; | 
				
			||||
use Chamilo\FaqBundle\Entity\Question; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class FaqController | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqBundle\Controller | 
				
			||||
 */ | 
				
			||||
class FaqController extends Controller | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * Default index. Shows one category/question at a time. If you want to just show everything at once, use the | 
				
			||||
     * indexWithoutCollapse action instead. | 
				
			||||
     * | 
				
			||||
     * @param string $categorySlug | 
				
			||||
     * @param string $questionSlug | 
				
			||||
     * | 
				
			||||
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException | 
				
			||||
     * @return \Symfony\Component\HttpFoundation\Response | 
				
			||||
     */ | 
				
			||||
    public function indexAction($categorySlug, $questionSlug) | 
				
			||||
    { | 
				
			||||
        if (!$categorySlug || !$questionSlug) { | 
				
			||||
            $redirect = $this->generateRedirectToDefaultSelection($categorySlug, $questionSlug); | 
				
			||||
            if ($redirect) { | 
				
			||||
                return $redirect; | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        // Otherwise get the selected category and/or question as usual | 
				
			||||
        $questions        = array(); | 
				
			||||
        $categories       = $this->getCategoryRepository()->retrieveActive(); | 
				
			||||
        $selectedCategory = $this->getSelectedCategory($categorySlug); | 
				
			||||
        $selectedQuestion = $this->getSelectedQuestion($questionSlug); | 
				
			||||
 | 
				
			||||
        if ($selectedCategory) { | 
				
			||||
            $questions = $selectedCategory->getQuestions(); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        // Throw 404 if there is no category in the database | 
				
			||||
        if (!$categories) { | 
				
			||||
            throw $this->createNotFoundException('You need at least 1 active faq category in the database'); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return $this->render( | 
				
			||||
            '@ChamiloFaq/Faq/index.html.twig', | 
				
			||||
            array( | 
				
			||||
                'categories'       => $categories, | 
				
			||||
                'questions'        => $questions, | 
				
			||||
                'selectedCategory' => $selectedCategory, | 
				
			||||
                'selectedQuestion' => $selectedQuestion | 
				
			||||
            ) | 
				
			||||
        ); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Index without any collapsing. Will just show all categories and questions at once. | 
				
			||||
     * | 
				
			||||
     * @param string $categorySlug | 
				
			||||
     * | 
				
			||||
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException | 
				
			||||
     * @return \Symfony\Component\HttpFoundation\Response | 
				
			||||
     */ | 
				
			||||
    public function indexWithoutCollapseAction($categorySlug) | 
				
			||||
    { | 
				
			||||
        if ($categorySlug) { | 
				
			||||
            $categories = $this->getCategoryRepository()->retrieveActiveBySlug($categorySlug); | 
				
			||||
        } else { | 
				
			||||
            $categories = $this->getCategoryRepository()->retrieveActive(); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        if (!$categories) { | 
				
			||||
            throw $this->createNotFoundException('Faq category not found'); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return $this->render( | 
				
			||||
            '@ChamiloFaq/Faq/index_without_collapse.html.twig', | 
				
			||||
            array( | 
				
			||||
                'categories'   => $categories, | 
				
			||||
                'categorySlug' => $categorySlug | 
				
			||||
            ) | 
				
			||||
        ); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 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\NotFoundHttpException | 
				
			||||
     */ | 
				
			||||
    protected function generateRedirectToDefaultSelection($categorySlug, $questionSlug) | 
				
			||||
    { | 
				
			||||
        $doRedirect = false; | 
				
			||||
        //$config = $this->container->getParameter('faq'); | 
				
			||||
        $config = []; | 
				
			||||
        $config['select_first_category_by_default'] = true; | 
				
			||||
        $config['select_first_question_by_default'] = true; | 
				
			||||
 | 
				
			||||
        if (!$categorySlug && $config['select_first_category_by_default']) { | 
				
			||||
            $firstCategory = $this->getCategoryRepository()->retrieveFirst(); | 
				
			||||
            if ($firstCategory instanceof 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 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('faq', array('categorySlug' => $categorySlug, 'questionSlug' => $questionSlug), true) | 
				
			||||
            ); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return false; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param string $questionSlug | 
				
			||||
     * | 
				
			||||
     * @return \Genj\FaqBundle\Entity\Question | 
				
			||||
     */ | 
				
			||||
    protected function getSelectedQuestion($questionSlug = null) | 
				
			||||
    { | 
				
			||||
        $selectedQuestion = null; | 
				
			||||
 | 
				
			||||
        if ($questionSlug !== null) { | 
				
			||||
            $selectedQuestion = $this->getQuestionRepository()->findOneBySlug($questionSlug); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return $selectedQuestion; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param string $categorySlug | 
				
			||||
     * | 
				
			||||
     * @return \Genj\FaqBundle\Entity\Category | 
				
			||||
     */ | 
				
			||||
    protected function getSelectedCategory($categorySlug = null) | 
				
			||||
    { | 
				
			||||
        $selectedCategory = null; | 
				
			||||
 | 
				
			||||
        if ($categorySlug !== null) { | 
				
			||||
            $selectedCategory = $this->getCategoryRepository()->findOneBy(array('isActive' => true, 'slug' => $categorySlug)); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return $selectedCategory; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return \Genj\FaqBundle\Entity\QuestionRepository | 
				
			||||
     */ | 
				
			||||
    protected function getQuestionRepository() | 
				
			||||
    { | 
				
			||||
        return $this->container->get('genj_faq.entity.question_repository'); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return \Genj\FaqBundle\Entity\CategoryRepository | 
				
			||||
     */ | 
				
			||||
    protected function getCategoryRepository() | 
				
			||||
    { | 
				
			||||
        return $this->container->get('genj_faq.entity.category_repository'); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,27 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\DependencyInjection; | 
				
			||||
 | 
				
			||||
use Symfony\Component\DependencyInjection\ContainerBuilder; | 
				
			||||
use Symfony\Component\Config\FileLocator; | 
				
			||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | 
				
			||||
use Symfony\Component\DependencyInjection\Loader; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * This is the class that loads and manages your bundle configuration | 
				
			||||
 * | 
				
			||||
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} | 
				
			||||
 */ | 
				
			||||
class ChamiloFaqExtension extends Extension | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * {@inheritDoc} | 
				
			||||
     */ | 
				
			||||
    public function load(array $configs, ContainerBuilder $container) | 
				
			||||
    { | 
				
			||||
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | 
				
			||||
        $loader->load('admin.yml'); | 
				
			||||
        $loader->load('services.yml'); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,315 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Entity; | 
				
			||||
 | 
				
			||||
use Gedmo\Mapping\Annotation as Gedmo; | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class Category | 
				
			||||
 * | 
				
			||||
 * @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Entity\CategoryRepository") | 
				
			||||
 * @ORM\Table( | 
				
			||||
 *     name="faq_category", | 
				
			||||
 *     indexes={@ORM\Index(name="is_active_idx", columns={"is_active"})} | 
				
			||||
 * ) | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqBundle\Entity | 
				
			||||
 */ | 
				
			||||
class Category | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(type="integer") | 
				
			||||
     * @ORM\Id | 
				
			||||
     * @ORM\GeneratedValue(strategy="AUTO") | 
				
			||||
     */ | 
				
			||||
    protected $id; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\OneToMany(targetEntity="Question", mappedBy="category") | 
				
			||||
     */ | 
				
			||||
    protected $questions; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(type="string", length=255, nullable=false) | 
				
			||||
     */ | 
				
			||||
    protected $headline; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(type="text", nullable=true) | 
				
			||||
     */ | 
				
			||||
    protected $body; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\SortablePosition | 
				
			||||
     * @ORM\Column(name="rank", type="integer") | 
				
			||||
     */ | 
				
			||||
    protected $rank; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(name="is_active", type="boolean") | 
				
			||||
     */ | 
				
			||||
    protected $isActive; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\Timestampable(on="create") | 
				
			||||
     * @ORM\Column(name="created_at", type="datetime") | 
				
			||||
     */ | 
				
			||||
    protected $createdAt; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\Timestampable(on="update") | 
				
			||||
     * @ORM\Column(name="updated_at", type="datetime") | 
				
			||||
     */ | 
				
			||||
    protected $updatedAt; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\Slug(fields={"headline"}, updatable=false) | 
				
			||||
     * @ORM\Column(type="string", length=50, nullable=false) | 
				
			||||
     */ | 
				
			||||
    protected $slug; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get id | 
				
			||||
     * | 
				
			||||
     * @return integer | 
				
			||||
     */ | 
				
			||||
    public function getId() | 
				
			||||
    { | 
				
			||||
        return $this->id; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set headline | 
				
			||||
     * | 
				
			||||
     * @param string $headline | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function setHeadline($headline) | 
				
			||||
    { | 
				
			||||
        $this->headline = $headline; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get headline | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getHeadline() | 
				
			||||
    { | 
				
			||||
        return $this->headline; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get body | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getBody() | 
				
			||||
    { | 
				
			||||
        return $this->body; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set body | 
				
			||||
     * | 
				
			||||
     * @param string $body | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setBody($body) | 
				
			||||
    { | 
				
			||||
        $this->body = $body; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get rank | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getRank() | 
				
			||||
    { | 
				
			||||
        return $this->rank; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set rank | 
				
			||||
     * | 
				
			||||
     * @param string $rank | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setRank($rank) | 
				
			||||
    { | 
				
			||||
        $this->rank = $rank; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set is_active | 
				
			||||
     * | 
				
			||||
     * @param boolean $isActive | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function setIsActive($isActive) | 
				
			||||
    { | 
				
			||||
        $this->isActive = $isActive; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get isActive | 
				
			||||
     * | 
				
			||||
     * @return boolean | 
				
			||||
     */ | 
				
			||||
    public function getIsActive() | 
				
			||||
    { | 
				
			||||
        return $this->isActive; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set createdAt | 
				
			||||
     * | 
				
			||||
     * @param \DateTime $createdAt | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function setCreatedAt(\DateTime $createdAt) | 
				
			||||
    { | 
				
			||||
        $this->createdAt = $createdAt; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get createdAt | 
				
			||||
     * | 
				
			||||
     * @return \DateTime | 
				
			||||
     */ | 
				
			||||
    public function getCreatedAt() | 
				
			||||
    { | 
				
			||||
        return $this->createdAt; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set updatedAt | 
				
			||||
     * | 
				
			||||
     * @param \DateTime $updatedAt | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function setUpdatedAt(\DateTime $updatedAt) | 
				
			||||
    { | 
				
			||||
        $this->updatedAt = $updatedAt; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get updatedAt | 
				
			||||
     * | 
				
			||||
     * @return \DateTime | 
				
			||||
     */ | 
				
			||||
    public function getUpdatedAt() | 
				
			||||
    { | 
				
			||||
        return $this->updatedAt; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set slug | 
				
			||||
     * | 
				
			||||
     * @param string $slug | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function setSlug($slug) | 
				
			||||
    { | 
				
			||||
        $this->slug = $slug; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get slug | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getSlug() | 
				
			||||
    { | 
				
			||||
        return $this->slug; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Add question | 
				
			||||
     * | 
				
			||||
     * @param Question $question | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function addQuestion(Question $question) | 
				
			||||
    { | 
				
			||||
        $this->questions[] = $question; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Remove question | 
				
			||||
     * | 
				
			||||
     * @param Question $question | 
				
			||||
     */ | 
				
			||||
    public function removeQuestion(Question $question) | 
				
			||||
    { | 
				
			||||
        $this->questions->removeElement($question); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get questions | 
				
			||||
     * | 
				
			||||
     * @return \Doctrine\Common\Collections\Collection | 
				
			||||
     */ | 
				
			||||
    public function getQuestions() | 
				
			||||
    { | 
				
			||||
        return $this->questions; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns a string representation of this object | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function __toString() | 
				
			||||
    { | 
				
			||||
        return $this->getHeadline(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns the route name for url generation | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getRouteName() | 
				
			||||
    { | 
				
			||||
        return 'faq'; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns the route parameters for url generation | 
				
			||||
     * | 
				
			||||
     * @return array | 
				
			||||
     */ | 
				
			||||
    public function getRouteParameters() | 
				
			||||
    { | 
				
			||||
        return array( | 
				
			||||
            'categorySlug' => $this->getSlug() | 
				
			||||
        ); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,63 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Entity; | 
				
			||||
 | 
				
			||||
use Doctrine\ORM\EntityRepository; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class CategoryRepository | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqBundle\Entity | 
				
			||||
 */ | 
				
			||||
class CategoryRepository extends EntityRepository | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @return mixed | 
				
			||||
     */ | 
				
			||||
    public function retrieveActive() | 
				
			||||
    { | 
				
			||||
        $query = $this->createQueryBuilder('c') | 
				
			||||
            ->where('c.isActive = :isActive') | 
				
			||||
            ->orderBy('c.rank', 'ASC') | 
				
			||||
            ->getQuery(); | 
				
			||||
 | 
				
			||||
        $query->setParameter('isActive', true); | 
				
			||||
 | 
				
			||||
        return $query->execute(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param string $slug | 
				
			||||
     * | 
				
			||||
     * @return mixed | 
				
			||||
     */ | 
				
			||||
    public function retrieveActiveBySlug($slug) | 
				
			||||
    { | 
				
			||||
        $query = $this->createQueryBuilder('c') | 
				
			||||
            ->where('c.isActive = :isActive') | 
				
			||||
            ->andWhere('c.slug = :slug') | 
				
			||||
            ->orderBy('c.rank', 'ASC') | 
				
			||||
            ->getQuery(); | 
				
			||||
 | 
				
			||||
        $query->setParameter('isActive', true); | 
				
			||||
        $query->setParameter('slug', $slug); | 
				
			||||
 | 
				
			||||
        return $query->execute(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return Category|null | 
				
			||||
     */ | 
				
			||||
    public function retrieveFirst() | 
				
			||||
    { | 
				
			||||
        $query = $this->createQueryBuilder('c') | 
				
			||||
            ->where('c.isActive = :isActive') | 
				
			||||
            ->orderBy('c.rank', 'ASC') | 
				
			||||
            ->setMaxResults(1) | 
				
			||||
            ->getQuery(); | 
				
			||||
 | 
				
			||||
        $query->setParameter('isActive', true); | 
				
			||||
 | 
				
			||||
        return $query->getOneOrNullResult(); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,313 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Entity; | 
				
			||||
 | 
				
			||||
use Gedmo\Mapping\Annotation as Gedmo; | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class Question | 
				
			||||
 * | 
				
			||||
 * @ORM\MappedSuperclass | 
				
			||||
 * @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Entity\QuestionRepository") | 
				
			||||
 * @ORM\Table(name="faq_question") | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqBundle\Entity | 
				
			||||
 */ | 
				
			||||
class Question | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(type="integer") | 
				
			||||
     * @ORM\Id | 
				
			||||
     * @ORM\GeneratedValue(strategy="AUTO") | 
				
			||||
     */ | 
				
			||||
    protected $id; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\ManyToOne(targetEntity="Category", inversedBy="questions") | 
				
			||||
     * @ORM\OrderBy({"rank" = "asc"}) | 
				
			||||
     */ | 
				
			||||
    protected $category; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(type="string", length=255, nullable=false) | 
				
			||||
     */ | 
				
			||||
    protected $headline; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\Column(type="text", nullable=true) | 
				
			||||
     */ | 
				
			||||
    protected $body; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\SortablePosition | 
				
			||||
     * @ORM\Column(name="rank", type="integer") | 
				
			||||
     */ | 
				
			||||
    protected $rank; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\Timestampable(on="create") | 
				
			||||
     * @ORM\Column(name="created_at", type="datetime") | 
				
			||||
     */ | 
				
			||||
    protected $createdAt; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\Timestampable(on="update") | 
				
			||||
     * @ORM\Column(name="updated_at", type="datetime") | 
				
			||||
     */ | 
				
			||||
    protected $updatedAt; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\Slug(fields={"headline"}, updatable=false) | 
				
			||||
     * @ORM\Column(type="string", length=50, nullable=false) | 
				
			||||
     */ | 
				
			||||
    protected $slug; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @var boolean | 
				
			||||
     * @ORM\Column(name="only_auth_users", type="boolean", nullable=false) | 
				
			||||
     */ | 
				
			||||
    protected $onlyAuthUsers; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get id | 
				
			||||
     * | 
				
			||||
     * @return integer | 
				
			||||
     */ | 
				
			||||
    public function getId() | 
				
			||||
    { | 
				
			||||
        return $this->id; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set headline | 
				
			||||
     * | 
				
			||||
     * @param string $headline | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setHeadline($headline) | 
				
			||||
    { | 
				
			||||
        $this->headline = $headline; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get headline | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getHeadline() | 
				
			||||
    { | 
				
			||||
        return $this->headline; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set body | 
				
			||||
     * | 
				
			||||
     * @param string $body | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setBody($body) | 
				
			||||
    { | 
				
			||||
        $this->body = $body; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get rank | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getRank() | 
				
			||||
    { | 
				
			||||
        return $this->rank; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set rank | 
				
			||||
     * | 
				
			||||
     * @param string $rank | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setRank($rank) | 
				
			||||
    { | 
				
			||||
        $this->rank = $rank; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get body | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getBody() | 
				
			||||
    { | 
				
			||||
        return $this->body; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set createdAt | 
				
			||||
     * | 
				
			||||
     * @param \DateTime $createdAt | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setCreatedAt($createdAt) | 
				
			||||
    { | 
				
			||||
        $this->createdAt = $createdAt; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get createdAt | 
				
			||||
     * | 
				
			||||
     * @return \DateTime | 
				
			||||
     */ | 
				
			||||
    public function getCreatedAt() | 
				
			||||
    { | 
				
			||||
        return $this->createdAt; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set updatedAt | 
				
			||||
     * | 
				
			||||
     * @param \DateTime $updatedAt | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setUpdatedAt($updatedAt) | 
				
			||||
    { | 
				
			||||
        $this->updatedAt = $updatedAt; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get updatedAt | 
				
			||||
     * | 
				
			||||
     * @return \DateTime | 
				
			||||
     */ | 
				
			||||
    public function getUpdatedAt() | 
				
			||||
    { | 
				
			||||
        return $this->updatedAt; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set slug | 
				
			||||
     * | 
				
			||||
     * @param string $slug | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setSlug($slug) | 
				
			||||
    { | 
				
			||||
        $this->slug = $slug; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get slug | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getSlug() | 
				
			||||
    { | 
				
			||||
        return $this->slug; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set category | 
				
			||||
     * | 
				
			||||
     * @param Category $category | 
				
			||||
     * | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setCategory(Category $category = null) | 
				
			||||
    { | 
				
			||||
        $this->category = $category; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get category | 
				
			||||
     * | 
				
			||||
     * @return Category | 
				
			||||
     */ | 
				
			||||
    public function getCategory() | 
				
			||||
    { | 
				
			||||
        return $this->category; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns a string representation of this object | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function __toString() | 
				
			||||
    { | 
				
			||||
        return $this->getHeadline(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns the route name for url generation | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getRouteName() | 
				
			||||
    { | 
				
			||||
        return 'faq'; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns the route parameters for url generation | 
				
			||||
     * | 
				
			||||
     * @return array | 
				
			||||
     */ | 
				
			||||
    public function getRouteParameters() | 
				
			||||
    { | 
				
			||||
        return array( | 
				
			||||
            'categorySlug' => $this->getCategory()->getSlug(), | 
				
			||||
            'questionSlug' => $this->getSlug() | 
				
			||||
        ); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Returns a string representation of the entity build out of BundleName + EntityName + EntityId | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getEntityIdentifier() | 
				
			||||
    { | 
				
			||||
        return 'GenjFaqBundle:Question:' . $this->getId(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return boolean | 
				
			||||
     */ | 
				
			||||
    public function isOnlyAuthUsers() | 
				
			||||
    { | 
				
			||||
        return $this->onlyAuthUsers; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param boolean $onlyAuthUsers | 
				
			||||
     * @return Question | 
				
			||||
     */ | 
				
			||||
    public function setOnlyAuthUsers($onlyAuthUsers) | 
				
			||||
    { | 
				
			||||
        $this->onlyAuthUsers = $onlyAuthUsers; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -0,0 +1,32 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
namespace Chamilo\FaqBundle\Entity; | 
				
			||||
 | 
				
			||||
use Doctrine\ORM\EntityRepository; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class QuestionRepository | 
				
			||||
 * | 
				
			||||
 * @package Genj\FaqBundle\Entity | 
				
			||||
 */ | 
				
			||||
class QuestionRepository extends EntityRepository | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @param string $categorySlug | 
				
			||||
     * | 
				
			||||
     * @return Question|null | 
				
			||||
     */ | 
				
			||||
    public function retrieveFirstByCategorySlug($categorySlug) | 
				
			||||
    { | 
				
			||||
        $query = $this->createQueryBuilder('q') | 
				
			||||
            ->join('q.category', 'c') | 
				
			||||
            ->where('c.slug = :categorySlug') | 
				
			||||
            ->orderBy('q.rank', 'ASC') | 
				
			||||
            ->setMaxResults(1) | 
				
			||||
            ->getQuery(); | 
				
			||||
 | 
				
			||||
        $query->setParameter('categorySlug', $categorySlug); | 
				
			||||
 | 
				
			||||
        return $query->getOneOrNullResult(); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,19 @@ | 
				
			||||
services: | 
				
			||||
 | 
				
			||||
    sonata.admin.faq_question: | 
				
			||||
        class: Chamilo\FaqBundle\Admin\QuestionAdmin | 
				
			||||
        tags: | 
				
			||||
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "FAQ" } | 
				
			||||
        arguments: | 
				
			||||
            - ~ | 
				
			||||
            - Chamilo\FaqBundle\Entity\Question | 
				
			||||
            - ~ | 
				
			||||
 | 
				
			||||
    sonata.admin.faq_category: | 
				
			||||
        class: Chamilo\FaqBundle\Admin\CategoryAdmin | 
				
			||||
        tags: | 
				
			||||
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "FAQ category" } | 
				
			||||
        arguments: | 
				
			||||
            - ~ | 
				
			||||
            - Chamilo\FaqBundle\Entity\Category | 
				
			||||
            - ~ | 
				
			||||
@ -0,0 +1,8 @@ | 
				
			||||
faq: | 
				
			||||
    pattern:  /faq/{categorySlug}/{questionSlug} | 
				
			||||
    defaults: { _controller: ChamiloFaqBundle:Faq:index, categorySlug: null, questionSlug: null } | 
				
			||||
 | 
				
			||||
# Shows the entire FAQ at once, without collapsing any categories or questions. Useful if your FAQ is not that big. | 
				
			||||
faq_without_collapse: | 
				
			||||
    pattern:  /faq-without-collapse/{categorySlug} | 
				
			||||
    defaults: { _controller: ChamiloFaqBundle:Faq:indexWithoutCollapse, categorySlug: null } | 
				
			||||
@ -0,0 +1,18 @@ | 
				
			||||
parameters: | 
				
			||||
    genj_faq.entity.question.class: Chamilo\FaqBundle\Entity\Question | 
				
			||||
    genj_faq.entity.category.class: Chamilo\FaqBundle\Entity\Category | 
				
			||||
    genj_faq.entity.question_repository.class: Genj\FaqBundle\Entity\QuestionRepository | 
				
			||||
    genj_faq.entity.category_repository.class: Genj\FaqBundle\Entity\CategoryRepository | 
				
			||||
 | 
				
			||||
services: | 
				
			||||
    genj_faq.entity.question_repository: | 
				
			||||
        factory_service: doctrine | 
				
			||||
        factory_method: getRepository | 
				
			||||
        class: %genj_faq.entity.question_repository.class% | 
				
			||||
        arguments: [%genj_faq.entity.question.class%] | 
				
			||||
 | 
				
			||||
    genj_faq.entity.category_repository: | 
				
			||||
        factory_service: doctrine | 
				
			||||
        factory_method: getRepository | 
				
			||||
        class: %genj_faq.entity.category_repository.class% | 
				
			||||
        arguments: [%genj_faq.entity.category.class%] | 
				
			||||
@ -0,0 +1,34 @@ | 
				
			||||
<h1>FAQ</h1> | 
				
			||||
 | 
				
			||||
<h2>Categories</h2> | 
				
			||||
<ul> | 
				
			||||
    {% for category in categories %} | 
				
			||||
        {% if selectedCategory.slug is defined and selectedCategory.slug == category.slug%} | 
				
			||||
            <li class="active"  > | 
				
			||||
                <strong>{{ category.headline|e }}</strong> | 
				
			||||
            </li> | 
				
			||||
        {% else %} | 
				
			||||
            <li> | 
				
			||||
                <a href="{{ path('faq', { 'categorySlug': category.slug }) }}">{{ category.headline|e }}</a> | 
				
			||||
            </li> | 
				
			||||
        {% endif %} | 
				
			||||
    {% endfor %} | 
				
			||||
</ul> | 
				
			||||
 | 
				
			||||
{% if selectedCategory is not null %} | 
				
			||||
    <h2>Questions</h2> | 
				
			||||
    <ul> | 
				
			||||
        {% for question in questions %} | 
				
			||||
            {% if selectedQuestion.slug is defined and selectedQuestion.slug == question.slug%} | 
				
			||||
                <li class="active"  > | 
				
			||||
                    <strong>{{ question.headline|e }}</strong> | 
				
			||||
                    <div>{{ selectedQuestion.body }}</div> | 
				
			||||
                </li> | 
				
			||||
            {% else %} | 
				
			||||
                <li> | 
				
			||||
                    <a href="{{ path('faq', { 'categorySlug': selectedCategory.slug, 'questionSlug': question.slug }) }}">{{ question.headline|e }}</a> | 
				
			||||
                </li> | 
				
			||||
            {% endif %} | 
				
			||||
        {% endfor %} | 
				
			||||
    </ul> | 
				
			||||
{% endif %} | 
				
			||||
@ -0,0 +1,9 @@ | 
				
			||||
<h1>FAQ</h1> | 
				
			||||
 | 
				
			||||
{% for category in categories %} | 
				
			||||
    <h2>{{ category.headline|e }}</h2> | 
				
			||||
    {% for question in category.questions %} | 
				
			||||
        <p><strong>{{ question.headline|e }}</strong></p> | 
				
			||||
        <p>{{ question.body }}</p> | 
				
			||||
    {% endfor %} | 
				
			||||
{% endfor %} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue