<commit_before><?php

namespace Admin\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Admin\AdminBundle\Entity\Livres;
use Admin\AdminBundle\Form\LivresType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
/**
 * Livres controller.
 *
 */
class LivresController extends Controller
{

    /**
     * Lists all Livres entities.
     *
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();

        //$entities = $em->getRepository('AdminBundle:Livres')->findAll();
        $entities = $em->getRepository('AdminBundle:Livres')->findBy(array(),array('titre'=>'asc'));

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

        if ($form->isValid()) {

            //ajoute image physique
            $file = $form->get('image')->getNormData();
            if($file != null) {               
                $fileName = md5(uniqid()).'.'.$file->guessExtension();
                $imagesDir = $this->container->getParameter('kernel.root_dir').'/../web/img/collection';
                $file->move($imagesDir, $fileName);
                $entity->setImage($fileName);
                $entity->setImageName($fileName);
            }
            //persiste l'entité
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('livres_show', array('id' => $entity->getId())));
        }

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

    /**
     * Creates a form to create a Livres entity.
     *
     * @param Livres $entity The entity
     *<commit_msg>retour accueil crud livres apres ajout element<commit_after><?php

namespace Admin\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Admin\AdminBundle\Entity\Livres;
use Admin\AdminBundle\Form\LivresType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
/**
 * Livres controller.
 *
 */
class LivresController extends Controller
{

    /**
     * Lists all Livres entities.
     *
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();

        //$entities = $em->getRepository('AdminBundle:Livres')->findAll();
        $entities = $em->getRepository('AdminBundle:Livres')->findBy(array(),array('titre'=>'asc'));

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

        if ($form->isValid()) {

            //ajoute image physique
            $file = $form->get('image')->getNormData();
            if($file != null) {               
                $fileName = md5(uniqid()).'.'.$file->guessExtension();
                $imagesDir = $this->container->getParameter('kernel.root_dir').'/../web/img/collection';
                $file->move($imagesDir, $fileName);
                $entity->setImage($fileName);
                $entity->setImageName($fileName);
            }
            //persiste l'entité
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('livres', array('id' => $entity->getId())));
        }

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

    /**
     * Creates a form to create a Livres entity.
     *
     * @param Livres $entity The entity
     *
{'fraction_non_alphanumeric': 0.16209939619136088, 'fraction_numerical': 0.00046446818392940084, 'mean_word_length': 2.270311313591496, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, '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': '2270640', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1233, 'n_words': 204}