<commit_before><?php

/**
 * This file is part of Usignolo.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Usignolo\Bundle\UsignoloBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

// these import the "@Route" and "@Template" annotations
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Usignolo\Bundle\UsignoloBundle\Entity\Issue;

class HomeController extends Controller
{
    /**
     * @Route("/", name="_home")
     * @Template()
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();
        $repository = $em->getRepository('UsignoloBundle:Issue');

        $issues = $repository->findAll();

        $form = $this->createFormBuilder(new Issue())
            ->add('title', 'text')
            ->add('description', 'textarea')
            ->add('save', 'submit')
            ->getForm();

        return array(
            'issues' => $issues,
            'form' => $form->createView(),
        );
    }
}
<commit_msg>Form management<commit_after><?php

/**
 * This file is part of Usignolo.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Usignolo\Bundle\UsignoloBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

// these import the "@Route" and "@Template" annotations
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Usignolo\Bundle\UsignoloBundle\Entity\Issue;

class HomeController extends Controller
{
    /**
     * @Route("/", name="_home")
     * @Template()
     */
    public function indexAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $repository = $em->getRepository('UsignoloBundle:Issue');

        $issues = $repository->findAll();

        $issue = new Issue();

        $form = $this->createFormBuilder($issue)
            ->add('title', 'text')
            ->add('description', 'textarea')
            ->add('save', 'submit')
            ->getForm();

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em->persist($issue);
            $em->flush();

            return $this->redirect($this->generateUrl('_welcome'));
        }

        return array(
            'issues' => $issues,
            'form' => $form->createView(),
        );
    }
}

{'fraction_non_alphanumeric': 0.14909359970403255, 'fraction_numerical': 0.0, 'mean_word_length': 2.808450704225352, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, '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': '6540680', 'n_tokens_mistral': 763, 'n_tokens_neox': 747, 'n_words': 169}