%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emtnaeewxm/www/src/EEM/VenteBundle/Controller/
Upload File :
Create Path :
Current File : /home/emtnaeewxm/www/src/EEM/VenteBundle/Controller/TresorieController.php

<?php

namespace EEM\VenteBundle\Controller;

use EEM\FonctionnaliteBundle\Service\TresorieService;
use EEM\VenteBundle\Entity\Tresorie;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

/**
 * Tresorie controller.
 *
 * @Route("/admin/tresorie")
 * @Security("has_role('ROLE_USER')")
 */
class TresorieController extends Controller
{
    /**
     * Lists all tresorie entities.
     *
     * @Route("/", name="tresorie_index")
     * @Method("GET")
     */
    public function indexAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $tresorieService = new TresorieService($em);
        $tresorieService->controleExisteTresorie();
        $paginator = $this->get('knp_paginator');
        $tresories = $paginator->paginate(
            $em->getRepository('EEMVenteBundle:Tresorie')->findAll(), /* query NOT result */
            $request->query->getInt('page', 1)/* page number */, 10/* limit per page */
        );

        return $this->render('@EEMVente/tresorie/index.html.twig', array(
            'tresories' => $tresories,
        ));
    }


    /**
     * Displays a form to edit an existing tresorie entity.
     *
     * @Route("/{id}", name="tresorie_edit")
     * @Method({"GET", "POST"})
     */
    public function editAction(Request $request, Tresorie $tresorie)
    {
        $deleteForm = $this->createDeleteForm($tresorie);
        $editForm = $this->createForm('EEM\VenteBundle\Form\TresorieType', $tresorie);
        $editForm->handleRequest($request);

        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('tresorie_index');
        }

        return $this->render('@EEMVente/tresorie/edit.html.twig', array(
            'tresorie' => $tresorie,
            'form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }

    /**
     * Deletes a tresorie entity.
     *
     * @Route("/{id}/delete", name="tresorie_delete")
     * @Method("DELETE")
     */
    public function deleteAction(Request $request, Tresorie $tresorie)
    {
        $form = $this->createDeleteForm($tresorie);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->remove($tresorie);
            $em->flush();
        }

        return $this->redirectToRoute('tresorie_index');
    }

    /**
     * Creates a form to delete a tresorie entity.
     *
     * @param Tresorie $tresorie The tresorie entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createDeleteForm(Tresorie $tresorie)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('tresorie_delete', array('id' => $tresorie->getId())))
            ->setMethod('DELETE')
            ->getForm();
    }
}

Zerion Mini Shell 1.0