<commit_before><?php

namespace AppBundle\Controller;

use AppBundle\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Httpfoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Exception;
use AppBundle\Controller\BaseController;
use Symfony\Component\Validator\Constraints\DateTime;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * @Security("has_role('ROLE_ORGANISATIE')")
 */
class OrganisatieController extends BaseController
{
    /**
     * @Route("/organisatie/{page}/", name="organisatieGetContent", defaults={"page" = "Home"})
     * @Method("GET")
     */
    public function getOrganisatiePage($page)
    {
        $this->setBasicPageData('Organisatie');
        switch ($page) {
            case 'Home':
                return $this->getOrganisatieHomePage();
            case 'To-do lijst':
                return $this->getOrganisatieHomePage();
            case 'Instellingen':
                return $this->getOrganisatieHomePage();
            case 'Mails':
                return $this->getOrganisatieHomePage();
            case 'Inschrijvingen':
                return $this->getOrganisatieHomePage();
            case 'Juryzaken':
                return $this->getOrganisatieHomePage();
            case 'Financieel':
                return $this->getOrganisatieHomePage();
            case 'Mijn gegevens':
                return $this->getOrganisatieGegevensPage();
        }
    }

    private function getGegevens()
    {
        $userObject = $this->getUser();
        return $userObject->getAll();
    }

    private function getOrganisatieGegevensPage()
    {
        $gegevens = $this->getGegevens();
        return $this->render('organisatie/organisatieGegevens.html.twig', array(
            'menuItems' => $this->menuItems,
            'gegevens' => $gegevens,
        ));
    }

    private function getOrganisatieHomePage()
    {
        return $this->render('organisatie/organisatieIndex.html.twig', array(
            'menuItems' => $this->menuItems,
        ));
    }

    /**
     * @Route("/organisatie/edit/{fieldName}/{data}/", name="editGegevens", options={"expose"=true})
     * @Method("GET")
     */
    public function editGegevens($fieldName, $data)
    {
        /** @var User $userObject */
        $userObject = $this->getUser();
        $returnData = 'error';
        switch ($fieldName) {
            case 'username':
                $userObject->setUsername($data);
                $returnData = $userObject->getUsername();
                break;
            case 'voornaam':
                $userObject->setVoornaam($data);
                $returnData = $userObject->getVoornaam();
                break;
            case 'achternaam':
                $userObject->setAchternaam($data);
                $returnData = $userObject->getAchternaam();
                break;
            case 'email':
                $userObject->setEmail($data);
                $returnData = $userObject->getEmail();
                break;
            case 'verantwoordelijkheid':
                $userObject->setVerantwoordelijkheid($data);
                $returnData = $userObject->getVerantwoordelijkheid();
                break;
        }
        $em = $this->getDoctrine()->getManager();
        $em->persist($userObject);
        $em->flush();
        $response = new Response($returnData);
        return $response;
    }

    /**
     * @Route("/organisatie/edit/{fieldName}/", name="removeGegevens", options={"expose"=true})
     * @Method("GET")
     */
    public function removeGegevens($fieldName)
    {
        /** @var User $userObject */
        $userObject = $this->getUser();
        $returnData = 'error';
        switch ($fieldName) {
            case 'username':
                $returnData = $userObject->getUsername();
                break;
            case 'voornaam':
                $returnData = $userObject->getVoornaam();
                break;
            case 'achternaam':
                $returnData = $userObject->getAchternaam();
                break;
            case 'email':
                $returnData = $userObject->getEmail();
                break;
            case 'verantwoordelijkheid':
                $userObject->setVerantwoordelijkheid(null);
                $returnData = $userObject->getVerantwoordelijkheid();
                break;
        }
        $em = $this->getDoctrine()->getManager();
        $em->persist($userObject);
        $em->flush();
        $response = new Response($returnData);
        return $response;<commit_msg>refactoring<commit_after><?php

namespace AppBundle\Controller;

use AppBundle\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Httpfoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Exception;
use AppBundle\Controller\BaseController;
use Symfony\Component\Validator\Constraints\DateTime;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * @Security("has_role('ROLE_ORGANISATIE')")
 */
class OrganisatieController extends BaseController
{
    /**
     * @Route("/organisatie/{page}/", name="organisatieGetContent", defaults={"page" = "Home"})
     * @Method("GET")
     */
    public function getOrganisatiePage($page)
    {
        $this->setBasicPageData('Organisatie');
        switch ($page) {
            case 'Home':
                return $this->getOrganisatieHomePage();
            case 'To-do lijst':
                return $this->getOrganisatieHomePage();
            case 'Instellingen':
                return $this->getOrganisatieHomePage();
            case 'Mails':
                return $this->getOrganisatieHomePage();
            case 'Inschrijvingen':
                return $this->getOrganisatieHomePage();
            case 'Juryzaken':
                return $this->getOrganisatieHomePage();
            case 'Financieel':
                return $this->getOrganisatieHomePage();
            case 'Mijn gegevens':
                return $this->getOrganisatieGegevensPage();
        }
    }

    private function getGegevens()
    {
        $userObject = $this->getUser();
        return $userObject->getAll();
    }

    private function getOrganisatieGegevensPage()
    {
        $gegevens = $this->getGegevens();
        return $this->render('organisatie/organisatieGegevens.html.twig', array(
            'menuItems' => $this->menuItems,
            'gegevens' => $gegevens,
        ));
    }

    private function getOrganisatieHomePage()
    {
        return $this->render('organisatie/organisatieIndex.html.twig', array(
            'menuItems' => $this->menuItems,
        ));
    }

    /**
     * @Route("/organisatie/edit/{fieldName}/{data}/", name="editGegevens", options={"expose"=true})
     * @Method("GET")
     */
    public function editGegevens($fieldName, $data)
    {
        /** @var User $userObject */
        $userObject = $this->getUser();
        $returnData = 'error';
        switch ($fieldName) {
            case 'username':
                $userObject->setUsername($data);
                $returnData = $userObject->getUsername();
                break;
            case 'voornaam':
                $userObject->setVoornaam($data);
                $returnData = $userObject->getVoornaam();
                break;
            case 'achternaam':
                $userObject->setAchternaam($data);
                $returnData = $userObject->getAchternaam();
                break;
            case 'email':
                $userObject->setEmail($data);
                $returnData = $userObject->getEmail();
                break;
            case 'verantwoordelijkheid':
                $userObject->setVerantwoordelijkheid($data);
                $returnData = $userObject->getVerantwoordelijkheid();
                break;
        }
        $this->addToDB($userObject);
        $response = new Response($returnData);
        return $response;
    }

    /**
     * @Route("/organisatie/edit/{fieldName}/", name="removeGegevens", options={"expose"=true})
     * @Method("GET")
     */
    public function removeGegevens($fieldName)
    {
        /** @var User $userObject */
        $userObject = $this->getUser();
        $returnData = 'error';
        switch ($fieldName) {
            case 'username':
                $returnData = $userObject->getUsername();
                break;
            case 'voornaam':
                $returnData = $userObject->getVoornaam();
                break;
            case 'achternaam':
                $returnData = $userObject->getAchternaam();
                break;
            case 'email':
                $returnData = $userObject->getEmail();
                break;
            case 'verantwoordelijkheid':
                $userObject->setVerantwoordelijkheid(null);
                $returnData = $userObject->getVerantwoordelijkheid();
                break;
        }
        $this->addToDB($userObject);
        $response = new Response($returnData);
        return $response;
{'fraction_non_alphanumeric': 0.1311406282943285, 'fraction_numerical': 0.0, 'mean_word_length': 2.099313949689644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, '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': '2974458', 'n_tokens_mistral': 2671, 'n_tokens_neox': 2589, 'n_words': 411}