<commit_before><?php

namespace FrontBundle\Controller;

use BackBundle\Entity\Book;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class DefaultController extends Controller
{
    /**
     * @Route("/")
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction(Request $request)
    {
        $defaultData = array();
        $form = $this->createFormBuilder($defaultData)
            ->add('title', TextType::class)
            ->add('email', EmailType::class)
            ->add('theme', ChoiceType::class, array('choices' => array('Aventure', 'Action', 'Science')))
            ->add('categories', ChoiceType::class, array('choices' => array('Roman', 'Magazine', 'Nouvelle')))
            ->add('send', SubmitType::class)
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            // data is an array with "name", "email", and "message" keys
            $data = $form->getData();

        }

        return $this->render('FrontBundle:Default:index.html.twig', array('form' => $form->createView()));
    }


    /**
     * @Template()
     * @Route("/read/{token}", name="read_book")
     * @param $token
     * @return array
     * @internal param Request $request
     */
    public function readAction($token)
    {
        $repository = $this ->getDoctrine() ->getManager() ->getRepository('AppBundle:Book');<commit_msg>Fixed default controller with seach form<commit_after><?php

namespace FrontBundle\Controller;

use BackBundle\Entity\Book;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class DefaultController extends Controller
{
    /**
     * @Route("/")
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction(Request $request)
    {
        $defaultData = array();
        $form = $this->createFormBuilder($defaultData)
            ->add('title', TextType::class, array(
                'required' => false,
            ))
            ->add('theme', EntityType::class, array(
                    'class' => 'BackBundle:Theme',
                    'choice_label' => 'name',
                    'query_builder' => function(EntityRepository $er) {
                        return $er->createQueryBuilder('u')
                            ->orderBy('u.name', 'ASC');
                    })
            )
            ->add('categories', EntityType::class, array(
                    'class' => 'BackBundle:Category',
                    'choice_label' => 'name',
                    'query_builder' => function(EntityRepository $er) {
                        return $er->createQueryBuilder('u')
                            ->orderBy('u.name', 'ASC');
                    })
            )
            ->add('send', SubmitType::class)
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()){

            $data = $form->getData();
            $books = $this->getDoctrine()->getManager()-> getRepository('BackBundle:Book')
                -> searchBooks( $data ['title'], $data ['theme'], $data ['categories']);

        }

        return $this->render('FrontBundle:Default:index.html.twig', array('form' => $form->createView()));
    }


    /**
     * @Template()
     * @Route("/read/{token}", name="read_book")
     * @param $token
     * @return array
     * @internal param Request $request
     */
    public function readAction($token)
    {
        $repository = $this ->getDoctrine() ->getManager() ->getRepository('AppBundle:Book');
{'fraction_non_alphanumeric': 0.14965841161400512, 'fraction_numerical': 0.0, 'mean_word_length': 2.7390263367917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3394032', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1249, 'n_words': 223}