Commit a6465cc1 authored by Mat's avatar Mat

Ajoute une copie de GarageBundle (projet 180529_eval) pour la mettre sur le dépôt

parent 3410649b
Pipeline #54 failed with stages
<?php
namespace GarageBundle\Controller;
use GarageBundle\Entity\Categorie;
use GarageBundle\Form\CategorieType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class CategorieController extends Controller
{
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function createAction(Request $request)
{
$categorie = new Categorie();
$form = $this->createForm(CategorieType::class,$categorie );
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($categorie);
$em->flush();
$this->addFlash('success', "La catégorie a bien été créée");
return $this->redirectToRoute('garage_categorie_read');
}
return $this->render('GarageBundle:Categorie:create.html.twig', array(
'formCategorie' => $form->createView()
));
}
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$categories = $em->getRepository('GarageBundle:Categorie')->findAllForRead();
return $this->render('@Garage/Categorie/read.html.twig', array(
'categories' => $categories
));
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$categorie = $em->getRepository('GarageBundle:Categorie')->findOneForUpdate($id);
if ($categorie === null) {
throw $this->createNotFoundException();
}
$form = $this->createForm(CategorieType::class, $categorie);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->flush();
$this->addFlash('success', "La catégorie a bien été modifiée");
return $this->redirectToRoute('garage_categorie_read');
}
return $this->render('GarageBundle:Categorie:update.html.twig', array(
'id' => $id,
'formCategorie' => $form->createView()
));
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function deleteAction($id)
{
$em = $this->getDoctrine()->getManager();
$categorie = $em->getRepository('GarageBundle:Categorie')->findOneForDelete($id);
if ($categorie !== null)
{
$em->remove($categorie);
$this->addFlash('success', "La catégorie a bien été supprimée");
$em->flush();
}
return $this->redirectToRoute('garage_categorie_read');
}
}
<?php
namespace GarageBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function indexAction()
{
return $this->render('GarageBundle:Default:index.html.twig');
}
}
<?php
namespace GarageBundle\Controller;
use GarageBundle\Entity\Garage;
use GarageBundle\Form\GarageType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class GarageController extends Controller
{
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createAction(Request $request)
{
$garage = new Garage();
$form = $this->createForm(GarageType::class, $garage);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($garage);
$em->flush();
$this->addFlash('success', 'Votre garage a bien été sauvegardé.');
return $this->redirectToRoute('garage_read');
}
return $this->render('@Garage/Garage/create.html.twig', array(
'formGarage' => $form->createView()
));
}
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$garages = $em->getRepository('GarageBundle:Garage')->findAllForRead();
return $this->render('@Garage/Garage/read.html.twig', array(
'garages' => $garages
));
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$garage = $em->getRepository('GarageBundle:Garage')->findOneForUpdate($id);
if ($garage === null) {
throw $this->createNotFoundException();
}
$form = $this->createForm(GarageType::class, $garage);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->flush();
$this->addFlash('success', 'Votre garage a bien été modifié.');
return $this->redirectToRoute('garage_read');
}
return $this->render('@Garage/Garage/update.html.twig', array(
'id' => $id,
'formGarage' => $form->createView()
));
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function deleteAction($id)
{
$em = $this->getDoctrine()->getManager();
$garage = $em->getRepository('GarageBundle:Garage')->findOneForDelete($id);
if ($garage !== null)
{
$em->remove($garage);
$em->flush();
$this->addFlash('success', 'Votre garage a bien été supprimé.');
}
return $this->redirectToRoute('garage_read');
}
}
<?php
namespace GarageBundle\Controller;
use GarageBundle\Entity\Voiture;
use GarageBundle\Form\VoitureType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class VoitureController extends Controller
{
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createAction(Request $request)
{
$voiture = new Voiture();
$em = $this->getDoctrine()->getManager();
$garageDispo = $em->getRepository('GarageBundle:Garage')->findAvailable();
dump($garageDispo);
$form = $this->createForm(VoitureType::class, $voiture); //, array('garageDispo' => $garageDispo)
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->persist($voiture);
$em->flush();
$this->addFlash('success', 'Votre voiture a bien été sauvegardée.');
return $this->redirectToRoute('garage_voiture_read');
}
return $this->render('@Garage/Voiture/create.html.twig', array(
'formVoiture' => $form->createView()
));
}
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$voitures = $em->getRepository('GarageBundle:Voiture')->findAllForRead();
return $this->render('@Garage/Voiture/read.html.twig', array(
'voitures' => $voitures
));
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$voiture = $em->getRepository('GarageBundle:Voiture')->findOneForUpdate($id);
if ($voiture === null) {
throw $this->createNotFoundException();
}
$form = $this->createForm(VoitureType::class, $voiture);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->flush();
$this->addFlash('success', 'Votre voiture a bien été modifiée.');
return $this->redirectToRoute('garage_voiture_read');
}
return $this->render('@Garage/Voiture/update.html.twig', array(
'id' => $id,
'formVoiture' => $form->createView()
));
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function deleteAction($id)
{
$em = $this->getDoctrine()->getManager();
$voiture = $em->getRepository('GarageBundle:Voiture')->findOneForDelete($id);
if ($voiture !== null)
{
$em->remove($voiture);
$em->flush();
$this->addFlash('success', 'Votre voiture a bien été supprimée.');
}
return $this->redirectToRoute('garage_voiture_read');
}
}
<?php
namespace GarageBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Categorie
*
* @ORM\Table(name="categorie")
* @ORM\Entity(repositoryClass="GarageBundle\Repository\CategorieRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Categorie
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="modifiedAt", type="datetime", nullable=true)
*/
private $modifiedAt;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
*/
private $nom;
/**
* @var ArrayCollection
* @ORM\OneToMany(targetEntity="GarageBundle\Entity\Voiture", mappedBy="categorie")
*/
private $voitures;
/**
*
* @ORM\PrePersist()
*/
public function prePersist()
{
$this->createdAt = new \DateTime();
$this->modifiedAt = new \DateTime();
}
/**
*
* @ORM\PreUpdate()
*/
public function preUpdate()
{
$this->modifiedAt = new \DateTime();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Categorie
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set modifiedAt
*
* @param \DateTime $modifiedAt
*
* @return Categorie
*/
public function setModifiedAt($modifiedAt)
{
$this->modifiedAt = $modifiedAt;
return $this;
}
/**
* Get modifiedAt
*
* @return \DateTime
*/
public function getModifiedAt()
{
return $this->modifiedAt;
}
/**
* Set nom
*
* @param string $nom
*
* @return Categorie
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get nom
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Constructor
*/
public function __construct()
{
$this->voitures = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add voiture
*
* @param \GarageBundle\Entity\Voiture $voiture
*
* @return Categorie
*/
public function addVoiture(\GarageBundle\Entity\Voiture $voiture)
{
$this->voitures[] = $voiture;
return $this;
}
/**
* Remove voiture
*
* @param \GarageBundle\Entity\Voiture $voiture
*/
public function removeVoiture(\GarageBundle\Entity\Voiture $voiture)
{
$this->voitures->removeElement($voiture);
}
/**
* Get voitures
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getVoitures()
{
return $this->voitures;
}
}
<?php
namespace GarageBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Garage
*
* @ORM\Table(name="garage")
* @ORM\Entity(repositoryClass="GarageBundle\Repository\GarageRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Garage
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="modifiedAt", type="datetime", nullable=true)
*/
private $modifiedAt;
/**
* @var int
*
* @ORM\Column(name="capacite", type="integer", length=100)
*/
private $capacite;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="lieu", type="string", length=255)
*/
private $lieu;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="GarageBundle\Entity\Voiture", mappedBy="garage")
*/
private $voitures;
/**
*
* @ORM\PrePersist()
*/
public function prePersist()
{
$this->createdAt = new \DateTime();
$this->modifiedAt = new \DateTime();
}
/**
*
* @ORM\PreUpdate()
*/
public function preUpdate()
{
$this->modifiedAt = new \DateTime();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Garage
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set modifiedAt
*
* @param \DateTime $modifiedAt
*
* @return Garage
*/
public function setModifiedAt($modifiedAt)
{
$this->modifiedAt = $modifiedAt;
return $this;
}
/**
* Get modifiedAt
*
* @return \DateTime
*/
public function getModifiedAt()
{
return $this->modifiedAt;
}
/**
* Set capacite
*
* @param integer $capacite
*
* @return Garage
*/
public function setCapacite($capacite)
{
$this->capacite = $capacite;
return $this;
}
/**
* Get capacite
*
* @return integer
*/
public function getCapacite()
{
return $this->capacite;
}
/**
* Set lieu
*
* @param string $lieu
*
* @return Garage
*/
public function setLieu($lieu)
{
$this->lieu = $lieu;
return $this;
}
/**
* Get lieu
*
* @return string
*/
public function getLieu()
{
return $this->lieu;
}
/**
* Set nom
*
* @param string $nom
*
* @return Garage
*/
public function setNom($nom)
{