<commit_before><?php

namespace PHPReview\WebsiteBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use JMS\SecurityExtraBundle\Annotation\Secure;
use PHPReview\WebsiteBundle\Form;
use PHPReview\WebsiteBundle\Entity\Usuario as Usuario;

class UsuarioController extends Controller
{
    
    public function indexAction($name)
    {
        return $this->render('WebsiteBundle:Default:index.html.twig', array('name' => $name));
    }
        
    /**
     * @Template()
     */
    public function cadastroAction(){
        $em = $this->getDoctrine()->getEntityManager();
        $usuario = new Usuario();
        $request = $this->getRequest();
        
        $formulario = $this->createForm(new Form\UsuarioType(),$usuario);
        
        if ($request->getMethod() == "POST"){
            $form->bindRequest($request);
            
            if($form->isValid()){
              
              $usuario->criptografaSenha($this->get('security.encoder_factory'));
              $usuario->setRole('ROLE_USER');
              $usuario->setDtCriacao(date('Y-m-d H:i:s'));
              
              $em = $this->getDoctrine()->getEntityManager();
              $em->persist($usuario);
              $em->flush();

              $this->get('session')->setFlash('notice', 'Usuario criado com sucesso!');
              return $this->redirect($this->generateUrl('homepage_cadastro_sucesso'));   
            }
        }else{
            return array('form'=>$formulario->createView());
        }
        
    }
    
    /**
     * @Template()
     */
    public function sucessoAction(){
        
    }
}<commit_msg>#7 Alterando apresentacao e validacao do formulario<commit_after><?php

namespace PHPReview\WebsiteBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use JMS\SecurityExtraBundle\Annotation\Secure;
use PHPReview\WebsiteBundle\Form;
use PHPReview\WebsiteBundle\Entity\Usuario as Usuario;

class UsuarioController extends Controller
{
    
    public function indexAction($name)
    {
        return $this->render('WebsiteBundle:Default:index.html.twig', array('name' => $name));
    }
        
    /**
     * @Template()
     */
    public function cadastroAction(){
        $em = $this->getDoctrine()->getEntityManager();
        $usuario = new Usuario();
        $request = $this->getRequest();
        
        $formulario = $this->createForm(new Form\UsuarioType(),$usuario);
        
        if ($request->getMethod() == "POST"){
            $formulario->bindRequest($request);
            
            if($formulario->isValid()){
              
              $usuario->criptografaSenha($this->get('security.encoder_factory'));
              $usuario->setRole('ROLE_USER');
              $usuario->setDtCriacao(\DateTime::createFromFormat(\Datetime::ATOM, date(\Datetime::ATOM)));
              $usuario->setDtAtualizacao(\DateTime::createFromFormat(\Datetime::ATOM, date(\Datetime::ATOM)));
              
              $em = $this->getDoctrine()->getEntityManager();
              $em->persist($usuario);
              $em->flush();

              $this->get('session')->setFlash('notice', 'Usuario criado com sucesso!');
              return $this->redirect($this->generateUrl('homepage_cadastro_sucesso'));   
            }
        }
        
        return array('form'=>$formulario->createView());
        
    }
    
    /**
     * @Template()
     */
    public function sucessoAction(){
        return array();
    }
}
{'fraction_non_alphanumeric': 0.14837286265857694, 'fraction_numerical': 0.0002757859900717044, 'mean_word_length': 2.3992502343017805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 50, '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': '4553595', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1058, 'n_words': 143}