<commit_before><?php

namespace MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class DefaultController extends Controller
{
    /**
     * @Route("/")
     */
    public function indexAction()
    {
        return $this->render('MainBundle:Default:index.html.twig');
    }
}<commit_msg>Commit defaultcontroller<commit_after><?php

namespace MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;

abstract class DefaultController extends Controller
{

    protected function dbUpdate($method, $obj_record)
    {
    	$em = $this->getDoctrine()->getManager();
    	switch($method) {
    		case 'persist':
    			$em->persist($obj_record);
    			break;
    		case 'merge';
    			$em->merge($obj_record);
    			break;
    		case 'remove':
    			$em->remove($obj_record);
    			break;
    		default:
    			return false;
    	}
    	$em->flush();
    }

    protected function checkRole($wanted, $current) {
    	if($current == $wanted) {
    		return true;
    	}
    	else {
    		return false;
    	}
    }

    protected function saveImg($img) {
        $dossier = '/web/img/';
        $fichier = basename($img->getClientOriginalName());
        $taille_maxi = 10000000;
        $taille = $img->getClientSize();
        $extensions = array('image/png', 'image/gif', 'image/jpg', 'image/jpeg');
        $extension = $img->getMimeType();
        if(!in_array($extension, $extensions)) {
            $erreur = 'Vous devez uploader un fichier de type png, gif, jpg, jpeg.';
        }
        if($taille>$taille_maxi) {
            $erreur = 'Le fichier est trop volumineux.';
        }
        if(!isset($erreur)) {
            $fichier = strtr($fichier, 
                'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 
                'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
            $fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier);

            $img->move($dossier, $fichier);
            if(file_exists($dossier.$fichier)) {
                $erreur = 'Echec de l\'upload !';
            }

            return $fichier;
        }
        else {
            return $erreur;
        }
    }

    protected function insert($array) {
        $this->getDoctrine()->getConnection()->executeUpdate($array['sql'], $array['param']);
    }
}
{'fraction_non_alphanumeric': 0.14143028365960847, 'fraction_numerical': 0.003995205753096284, 'mean_word_length': 2.4826147426981917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '1683681', 'n_tokens_mistral': 861, 'n_tokens_neox': 842, 'n_words': 130}