<commit_before><?php

namespace Project\AppBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use JMS\SecurityExtraBundle\Annotation\Secure;
use Project\AppBundle\Entity\User;
use Project\AppBundle\Form\UserType;

class DefaultController extends Controller
{
    /**
     * Lists all User entities.
     *
     * @Secure(roles={"ROLE_MANAGER", "ROLE_SPEAKER", "ROLE_STUDENT"})
     * @Route("/", name="project_app_index")
     * @Method("GET")
     * @Template()
     */
    public function indexAction()
    {
        // Get logged in user
        $user = $this->getUser();
        $userRoles = $user->getRoles();

        if(in_array('ROLE_MANAGER', $userRoles)) {
            return $this->redirect($this->generateUrl('promotion'));
        } elseif(in_array('ROLE_SPEAKER', $userRoles)) {
            return $this->redirect($this->generateUrl('missing'));
        } elseif(in_array('ROLE_STUDENT', $userRoles)) {
            return $this->redirect($this->generateUrl('project_app_agenda_index'));
        }
    }
}<commit_msg>Implement default controller to redirect in function of role<commit_after><?php

namespace Project\AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use JMS\SecurityExtraBundle\Annotation\Secure;


class DefaultController extends Controller
{
    /**
     * Routes to the right application part in function of role.
     *
     * @Secure(roles={"ROLE_MANAGER", "ROLE_SPEAKER", "ROLE_STUDENT"})
     * @Route("/", name="project_app_index")
     * @Method("GET")
     * @Template()
     */
    public function indexAction()
    {
        // Get logged in user
        $user = $this->getUser();
        $userRoles = $user->getRoles();

        if(in_array('ROLE_MANAGER', $userRoles)) {
            // Redirect to promotion gestion
            return $this->redirect($this->generateUrl('promotion'));
        } elseif(in_array('ROLE_SPEAKER', $userRoles)) {
            // Redirect to missing list
            return $this->redirect($this->generateUrl('missing'));
        } elseif(in_array('ROLE_STUDENT', $userRoles)) {
            // Redirect to the agenda
            return $this->redirect($this->generateUrl('project_app_agenda_index'));
        }
    }
}
{'fraction_non_alphanumeric': 0.13383458646616542, 'fraction_numerical': 0.0, 'mean_word_length': 3.4797979797979797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1082842', 'n_tokens_mistral': 788, 'n_tokens_neox': 788, 'n_words': 134}