<commit_before><?php

namespace Numa\DOADMSBundle\Controller;

use Numa\DOAAdminBundle\Entity\Catalogrecords;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Numa\DOADMSBundle\Entity\DMSUser;
use Numa\DOADMSBundle\Form\DMSUserType;

/**
 * DMSUser controller.
 *
 */
class DMSUserController extends Controller
{

    /**
     * Lists all DMSUser entities.
     *
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();
        $user = $this->get('security.token_storage')->getToken()->getUser();
        if($user instanceof Catalogrecords){
            $entities = $em->getRepository('NumaDOADMSBundle:DMSUser')->findBy(array('Dealer'=>$user));
        }else {
            $entities = $em->getRepository('NumaDOADMSBundle:DMSUser')->findAll();
        }

        return $this->render('NumaDOADMSBundle:DMSUser:index.html.twig', array(
            'entities' => $entities,
        ));
    }
    /**
     * Creates a new DMSUser entity.
     *
     */
    public function createAction(Request $request)
    {
        $entity = new DMSUser();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            //get loged user

            $user = $this->get('security.token_storage')->getToken()->getUser();

            if($user instanceof Catalogrecords){
                $entity->setDealer($user);
            }


            $em->persist($entity);
            $em->flush();
            return $this->redirect($this->generateUrl('dmsuser'));

        }

        return $this->render('NumaDOADMSBundle:DMSUser:new.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView(),
        ));
    }

    /**
     * Creates a form to create a DMSUser entity.
     *
     * @param DMSUser $entity The entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createCreateForm(DMSUser $entity)
    {
        $form = $this->createForm(new DMSUserType(), $entity, array(
            'action' => $this->generateUrl('dmsuser_create'),
            'method' => 'POST',
        ));
<commit_msg>user creation dealer chooser<commit_after><?php

namespace Numa\DOADMSBundle\Controller;

use Numa\DOAAdminBundle\Entity\Catalogrecords;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Numa\DOADMSBundle\Entity\DMSUser;
use Numa\DOADMSBundle\Form\DMSUserType;

/**
 * DMSUser controller.
 *
 */
class DMSUserController extends Controller
{

    /**
     * Lists all DMSUser entities.
     *
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();
        $user = $this->get('security.token_storage')->getToken()->getUser();
        if($user instanceof Catalogrecords){
            $entities = $em->getRepository('NumaDOADMSBundle:DMSUser')->findBy(array('Dealer'=>$user));
        }else {
            $entities = $em->getRepository('NumaDOADMSBundle:DMSUser')->findAll();
        }

        return $this->render('NumaDOADMSBundle:DMSUser:index.html.twig', array(
            'entities' => $entities,
        ));
    }
    /**
     * Creates a new DMSUser entity.
     *
     */
    public function createAction(Request $request)
    {
        $entity = new DMSUser();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            //get loged user

            $dealer = $this->get("Numa.Dms.User")->getSignedDealer();

            if($dealer instanceof Catalogrecords){
                $entity->setDealer($dealer);
            }


            $em->persist($entity);
            $em->flush();
            return $this->redirect($this->generateUrl('dmsuser'));

        }

        return $this->render('NumaDOADMSBundle:DMSUser:new.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView(),
        ));
    }

    /**
     * Creates a form to create a DMSUser entity.
     *
     * @param DMSUser $entity The entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createCreateForm(DMSUser $entity)
    {
        $form = $this->createForm(new DMSUserType(), $entity, array(
            'action' => $this->generateUrl('dmsuser_create'),
            'method' => 'POST',
        ));

{'fraction_non_alphanumeric': 0.15146865409907936, 'fraction_numerical': 0.0, 'mean_word_length': 2.3700147710487443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 68, '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': '6435793', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1362, 'n_words': 227}