<commit_before><?php

namespace Spiralation\SiteBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Spiralation\EntityBundle\Entity\Volunteer;
use Spiralation\EntityBundle\Form\VolunteerType;
use Spiralation\EntityBundle\Entity\User;

use Spiralation\EntityBundle\Entity\Organization;
use Spiralation\EntityBundle\Form\OrganizationType;

class RegisterController extends Controller
{
    public function VolunteerAction(Request $request)
    {
       $volunteer = new Volunteer();
            $form = $this->createForm(new VolunteerType(), $volunteer, array(
                'action' => $this->generateUrl('create_volunteer'),
                'attr'  => array(
                    'class'=>'form-horizontal center'
                )
            ));
            
      
        $form->handleRequest($request);

        if ($form->isValid()) {
            $volunteer = $form->getData();
            $user = new User();
            $user->setPassword($<PASSWORD>());
            $user->setRole(1);
            $user->setVolunteer($volunteer->getVolunteerId());
            $user->setEmail($volunteer->getEmail());
        
        try{
            $em = $this->getDoctrine()->getManager();
            $em ->persist($volunteer);
            $em->persist($user);            
            $em->flush();
            }
            catch(\Exception $e){
                echo $e;
                return $this->render('SpiralationSiteBundle:Index:index.html.twig', array(
                    'type'  => 'E',
                    'message' => ' Opz! Something went wrong. Please Try again'
                    
                    
        ));
            }

            return $this->render('SpiralationSiteBundle:index:index.html.twig', array(
                    'type'  => 'S',
                    'message' => ' Congratulations! You are now an Volunteer. You can now sign in'
                    
        ));
        }
          
           return $this->render('SpiralationSiteBundle:Register:register.html.twig', array('form' => $form->createView())); 
        
    }

    public function formAndroidAction(Request $request)
    {
        /*$test = array(
            'email'=>'<EMAIL>',
            'password'=>'<PASSWORD>',
            'userName'=>'userName',
            'status'=>'OK'
        );

        $request = json_encode($test);*/

        $volunteer = json_decode($request);

        $email  = $volunteer->email;
        $password = $volunteer->password;

        $volunteer = new Volunteer();

        $volunteer->setEmail($email);
        $volunteer->setPassword($password);

        $em = $this->getDoctrine()->getManager();
        $em->persist($volunteer);

        try{
            $em->flush();
        }

        catch(\Exception $e){
            $respond = array(
                'status'=>'fail'
            );
            return json_encode($respond);
        }

        $respond = array(
            'status'=>'success'
        );
        return json_encode($respond);
    }
    
     public function OrganizationAction(Request $request)
    {
       $Organization = new Organization();
            $form = $this->createForm(new OrganizationType(), $Organization, array(
                'action' => $this->generateUrl('create_organization'),
                'attr'  => array(
                    'class'=>'form-horizontal center'
                )
            ));
            
       
        $form->handleRequest($request);

        if ($form->isValid()) {
            $Organization = $form->getData();
            $user = new User();
            $user->setPassword($Organization-><PASSWORD>());
            $user->setRole(2);
            $user->setOrganization($Organization->getOrganizationId());
            $user->setEmail($Organization->getEmail());
        
        try{
            $em = $this->getDoctrine()->getManager();
            $em ->persist($Organization);
            $em->persist($user);            
            $em->flush();
            }
            catch(\Exception $e){
                echo $e;
                return $this->render('SpiralationSiteBundle:Index:index.html.twig', array(
                    'type'  => 'E',
                    'message' => ' Opz! Something went wrong. Please Try again'
                    
                    
        ));
            }

            return $this->render('SpiralationSiteBundle:index:index.html.twig', array(
                    'type'  => 'S',
                    'message' => ' Congratulations! Your Organization is added. You can now sign in'
                    
        ));
        }
          
           return $this->render('SpiralationSiteBundle:Register:register.html.twig', array('form' => $form->createView())); 
        
    }
    
}
 <commit_msg>android comm<commit_after><?php

namespace Spiralation\SiteBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Spiralation\EntityBundle\Entity\Volunteer;
use Spiralation\EntityBundle\Form\VolunteerType;
use Spiralation\EntityBundle\Entity\User;

use Spiralation\EntityBundle\Entity\Organization;
use Spiralation\EntityBundle\Form\OrganizationType;

class RegisterController extends Controller
{
    public function VolunteerAction(Request $request)
    {
        $volunteer = new Volunteer();
        $form = $this->createForm(new VolunteerType(), $volunteer, array(
            'action' => $this->generateUrl('create_volunteer'),
            'attr' => array(
                'class' => 'form-horizontal center'
            )
        ));


        $form->handleRequest($request);

        if ($form->isValid()) {
            $volunteer = $form->getData();
            $user = new User();
            $user->setPassword($<PASSWORD>-><PASSWORD>());
            $user->setRole(1);
            $user->setVolunteer($volunteer->getVolunteerId());
            $user->setEmail($volunteer->getEmail());

            try {
                $em = $this->getDoctrine()->getManager();
                $em->persist($volunteer);
                $em->persist($user);
                $em->flush();
            } catch (\Exception $e) {
                echo $e;
                return $this->render('SpiralationSiteBundle:Index:index.html.twig', array(
                    'type' => 'E',
                    'message' => ' Opz! Something went wrong. Please Try again'


                ));
            }

            return $this->render('SpiralationSiteBundle:index:index.html.twig', array(
                'type' => 'S',
                'message' => ' Congratulations! You are now an Volunteer. You can now sign in'

            ));
        }

        return $this->render('SpiralationSiteBundle:Register:register.html.twig', array('form' => $form->createView()));

    }

    public function formAndroidAction(Request $request)
    {
        /*$test = array(
            'email'=>'<EMAIL>',
            'password'=>'<PASSWORD>',
            'userName'=>'userName',
            'status'=>'OK'
        );

        $request = json_encode($test);*/
        echo $request;
        if ($request != null) {
            $volunteer = json_decode($request);

            $email = $volunteer->email;
            $password = $volunteer->password;

            $volunteer = new Volunteer();

            $volunteer->setEmail($email);
            $volunteer->setPassword($password);

            $em = $this->getDoctrine()->getManager();
            $em->persist($volunteer);

            try {
                $em->flush();
            } catch (\Exception $e) {
                $respond = array(
                    'status' => 'fail'
                );
                return json_encode($respond);
            }

            $respond = array(
                'status' => 'success'
            );
            return json_encode($respond);
        }
    }

    public function OrganizationAction(Request $request)
    {
        $Organization = new Organization();
        $form = $this->createForm(new OrganizationType(), $Organization, array(
            'action' => $this->generateUrl('create_organization'),
            'attr' => array(
                'class' => 'form-horizontal center'
            )
        ));


        $form->handleRequest($request);

        if ($form->isValid()) {
            $Organization = $form->getData();
            $user = new User();
            $user->setPassword($Organization->getPassword());
            $user->setRole(2);
            $user->setOrganization($Organization->getOrganizationId());
            $user->setEmail($Organization->getEmail());

            try {
                $em = $this->getDoctrine()->getManager();
                $em->persist($Organization);
                $em->persist($user);
                $em->flush();
            } catch (\Exception $e) {
                echo $e;
                return $this->render('SpiralationSiteBundle:Index:index.html.twig', array(
                    'type' => 'E',
                    'message' => ' Opz! Something went wrong. Please Try again'


                ));
            }

            return $this->render('SpiralationSiteBundle:index:index.html.twig', array(
                'type' => 'S',
                'message' => ' Congratulations! Your Organization is added. You can now sign in'

            ));
        }

        return $this->render('SpiralationSiteBundle:Register:register.html.twig', array('form' => $form->createView()));

    }

}
 
{'fraction_non_alphanumeric': 0.14380113278791692, 'fraction_numerical': 0.0004195510803440319, 'mean_word_length': 1.7088068181818181, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 154, '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': '5394241', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2506, 'n_words': 431}