From a6465cc1582c5d8b23a64f6addffbcc07fee70e2 Mon Sep 17 00:00:00 2001
From: Mat
Date: Fri, 25 Jan 2019 12:33:37 +0100
Subject: [PATCH] =?UTF-8?q?Ajoute=20une=20copie=20de=20GarageBundle=20(pro?=
=?UTF-8?q?jet=20180529=5Feval)=20pour=20la=20mettre=20sur=20le=20d=C3=A9p?=
=?UTF-8?q?=C3=B4t?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/CategorieController.php | 96 +++++
.../Controller/DefaultController.php | 13 +
.../Controller/GarageController.php | 106 +++++
.../Controller/VoitureController.php | 110 ++++++
src/GarageBundle/Entity/Categorie.php | 194 +++++++++
src/GarageBundle/Entity/Garage.php | 262 ++++++++++++
src/GarageBundle/Entity/Voiture.php | 372 ++++++++++++++++++
src/GarageBundle/Form/CategorieType.php | 40 ++
src/GarageBundle/Form/GarageType.php | 51 +++
src/GarageBundle/Form/VoitureType.php | 78 ++++
src/GarageBundle/GarageBundle.php | 9 +
.../Repository/CategorieRepository.php | 55 +++
.../Repository/GarageRepository.php | 70 ++++
.../Repository/VoitureRepository.php | 56 +++
src/GarageBundle/Resources/config/routing.yml | 97 +++++
.../Resources/config/services.yml | 4 +
.../views/Categorie/create.html.twig | 16 +
.../Resources/views/Categorie/read.html.twig | 51 +++
.../views/Categorie/update.html.twig | 16 +
.../Resources/views/Default/footer.html.twig | 1 +
.../Resources/views/Default/index.html.twig | 74 ++++
.../Resources/views/Default/navbar.html.twig | 15 +
.../Resources/views/Garage/create.html.twig | 16 +
.../Resources/views/Garage/read.html.twig | 57 +++
.../Resources/views/Garage/update.html.twig | 16 +
.../Resources/views/Voiture/create.html.twig | 16 +
.../Resources/views/Voiture/read.html.twig | 61 +++
.../Resources/views/Voiture/update.html.twig | 16 +
.../Resources/views/layout.html.twig | 55 +++
29 files changed, 2023 insertions(+)
create mode 100644 src/GarageBundle/Controller/CategorieController.php
create mode 100755 src/GarageBundle/Controller/DefaultController.php
create mode 100755 src/GarageBundle/Controller/GarageController.php
create mode 100755 src/GarageBundle/Controller/VoitureController.php
create mode 100644 src/GarageBundle/Entity/Categorie.php
create mode 100644 src/GarageBundle/Entity/Garage.php
create mode 100644 src/GarageBundle/Entity/Voiture.php
create mode 100644 src/GarageBundle/Form/CategorieType.php
create mode 100755 src/GarageBundle/Form/GarageType.php
create mode 100755 src/GarageBundle/Form/VoitureType.php
create mode 100755 src/GarageBundle/GarageBundle.php
create mode 100755 src/GarageBundle/Repository/CategorieRepository.php
create mode 100755 src/GarageBundle/Repository/GarageRepository.php
create mode 100755 src/GarageBundle/Repository/VoitureRepository.php
create mode 100755 src/GarageBundle/Resources/config/routing.yml
create mode 100755 src/GarageBundle/Resources/config/services.yml
create mode 100755 src/GarageBundle/Resources/views/Categorie/create.html.twig
create mode 100755 src/GarageBundle/Resources/views/Categorie/read.html.twig
create mode 100755 src/GarageBundle/Resources/views/Categorie/update.html.twig
create mode 100755 src/GarageBundle/Resources/views/Default/footer.html.twig
create mode 100755 src/GarageBundle/Resources/views/Default/index.html.twig
create mode 100755 src/GarageBundle/Resources/views/Default/navbar.html.twig
create mode 100755 src/GarageBundle/Resources/views/Garage/create.html.twig
create mode 100755 src/GarageBundle/Resources/views/Garage/read.html.twig
create mode 100755 src/GarageBundle/Resources/views/Garage/update.html.twig
create mode 100755 src/GarageBundle/Resources/views/Voiture/create.html.twig
create mode 100755 src/GarageBundle/Resources/views/Voiture/read.html.twig
create mode 100755 src/GarageBundle/Resources/views/Voiture/update.html.twig
create mode 100755 src/GarageBundle/Resources/views/layout.html.twig
diff --git a/src/GarageBundle/Controller/CategorieController.php b/src/GarageBundle/Controller/CategorieController.php
new file mode 100644
index 0000000..17d1612
--- /dev/null
+++ b/src/GarageBundle/Controller/CategorieController.php
@@ -0,0 +1,96 @@
+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');
+
+ }
+}
diff --git a/src/GarageBundle/Controller/DefaultController.php b/src/GarageBundle/Controller/DefaultController.php
new file mode 100755
index 0000000..3ad9fbe
--- /dev/null
+++ b/src/GarageBundle/Controller/DefaultController.php
@@ -0,0 +1,13 @@
+render('GarageBundle:Default:index.html.twig');
+ }
+}
diff --git a/src/GarageBundle/Controller/GarageController.php b/src/GarageBundle/Controller/GarageController.php
new file mode 100755
index 0000000..7cd8d90
--- /dev/null
+++ b/src/GarageBundle/Controller/GarageController.php
@@ -0,0 +1,106 @@
+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');
+ }
+
+}
diff --git a/src/GarageBundle/Controller/VoitureController.php b/src/GarageBundle/Controller/VoitureController.php
new file mode 100755
index 0000000..2c34cde
--- /dev/null
+++ b/src/GarageBundle/Controller/VoitureController.php
@@ -0,0 +1,110 @@
+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');
+ }
+
+}
diff --git a/src/GarageBundle/Entity/Categorie.php b/src/GarageBundle/Entity/Categorie.php
new file mode 100644
index 0000000..78f40d2
--- /dev/null
+++ b/src/GarageBundle/Entity/Categorie.php
@@ -0,0 +1,194 @@
+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;
+ }
+}
diff --git a/src/GarageBundle/Entity/Garage.php b/src/GarageBundle/Entity/Garage.php
new file mode 100644
index 0000000..cc9222c
--- /dev/null
+++ b/src/GarageBundle/Entity/Garage.php
@@ -0,0 +1,262 @@
+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)
+ {
+ $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 Garage
+ */
+ 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;
+ }
+}
diff --git a/src/GarageBundle/Entity/Voiture.php b/src/GarageBundle/Entity/Voiture.php
new file mode 100644
index 0000000..f0c332d
--- /dev/null
+++ b/src/GarageBundle/Entity/Voiture.php
@@ -0,0 +1,372 @@
+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 Voiture
+ */
+ 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 Voiture
+ */
+ public function setModifiedAt($modifiedAt)
+ {
+ $this->modifiedAt = $modifiedAt;
+
+ return $this;
+ }
+
+ /**
+ * Get modifiedAt
+ *
+ * @return \DateTime
+ */
+ public function getModifiedAt()
+ {
+ return $this->modifiedAt;
+ }
+
+ /**
+ * Set marque
+ *
+ * @param string $marque
+ *
+ * @return Voiture
+ */
+ public function setMarque($marque)
+ {
+ $this->marque = $marque;
+
+ return $this;
+ }
+
+ /**
+ * Get marque
+ *
+ * @return string
+ */
+ public function getMarque()
+ {
+ return $this->marque;
+ }
+
+ /**
+ * Set modele
+ *
+ * @param string $modele
+ *
+ * @return Voiture
+ */
+ public function setModele($modele)
+ {
+ $this->modele = $modele;
+
+ return $this;
+ }
+
+ /**
+ * Get modele
+ *
+ * @return string
+ */
+ public function getModele()
+ {
+ return $this->modele;
+ }
+
+ /**
+ * Set path
+ *
+ * @param string $path
+ *
+ * @return Voiture
+ */
+ public function setPath($path)
+ {
+ $this->path = $path;
+
+ return $this;
+ }
+
+ /**
+ * Get path
+ *
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * Set annee
+ *
+ * @param integer $annee
+ *
+ * @return Voiture
+ */
+ public function setAnnee($annee)
+ {
+ $this->annee = $annee;
+
+ return $this;
+ }
+
+ /**
+ * Get annee
+ *
+ * @return integer
+ */
+ public function getAnnee()
+ {
+ return $this->annee;
+ }
+
+ /**
+ * Set dateAchat
+ *
+ * @param \DateTime $dateAchat
+ *
+ * @return Voiture
+ */
+ public function setDateAchat($dateAchat)
+ {
+ $this->dateAchat = $dateAchat;
+
+ return $this;
+ }
+
+ /**
+ * Get dateAchat
+ *
+ * @return \DateTime
+ */
+ public function getDateAchat()
+ {
+ return $this->dateAchat;
+ }
+
+ /**
+ * Set prix
+ *
+ * @param float $prix
+ *
+ * @return Voiture
+ */
+ public function setPrix($prix)
+ {
+ $this->prix = $prix;
+
+ return $this;
+ }
+
+ /**
+ * Get prix
+ *
+ * @return float
+ */
+ public function getPrix()
+ {
+ return $this->prix;
+ }
+
+ /**
+ * Set garage
+ *
+ * @param \GarageBundle\Entity\Garage $garage
+ *
+ * @return Voiture
+ */
+ public function setGarage(\GarageBundle\Entity\Garage $garage)
+ {
+ //$nbVoitures = ($this->getGarage()->getVoitures() === null) ? 0 : count($this->getGarage()->getVoitures());
+
+ //if ($nbVoitures < $this->getGarage()->getCapacite())
+ //{
+ $this->garage = $garage;
+ //}
+
+ return $this;
+ }
+
+ /**
+ * Get garage
+ *
+ * @return \GarageBundle\Entity\Garage
+ */
+ public function getGarage()
+ {
+ return $this->garage;
+ }
+
+ /**
+ * Set categorie
+ *
+ * @param \GarageBundle\Entity\Categorie $categorie
+ *
+ * @return Voiture
+ */
+ public function setCategorie(\GarageBundle\Entity\Categorie $categorie)
+ {
+ $this->categorie = $categorie;
+
+ return $this;
+ }
+
+ /**
+ * Get categorie
+ *
+ * @return \GarageBundle\Entity\Categorie
+ */
+ public function getCategorie()
+ {
+ return $this->categorie;
+ }
+}
diff --git a/src/GarageBundle/Form/CategorieType.php b/src/GarageBundle/Form/CategorieType.php
new file mode 100644
index 0000000..c185592
--- /dev/null
+++ b/src/GarageBundle/Form/CategorieType.php
@@ -0,0 +1,40 @@
+add('nom', TextType::class, array(
+ 'label' => "Nom",
+ 'label_attr' => array(),
+ 'attr' => array(),
+ ));
+ $builder->add('save', SubmitType::class, array(
+ 'label' => 'Enregistrer',
+ ));
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ parent::configureOptions($resolver);
+
+ $resolver->setDefault('data_class', Categorie::class);
+ $resolver->setDefault('attr', array('class' => 'categorie_type'));
+ }
+
+ public function getBlockPrefix()
+ {
+ return 'garage_bundle_categorie_type';
+ }
+}
\ No newline at end of file
diff --git a/src/GarageBundle/Form/GarageType.php b/src/GarageBundle/Form/GarageType.php
new file mode 100755
index 0000000..55df4a6
--- /dev/null
+++ b/src/GarageBundle/Form/GarageType.php
@@ -0,0 +1,51 @@
+add('nom', TextType::class, array(
+ 'label' => "Nom",
+ 'label_attr' => array(),
+ 'attr' => array(),
+ ));
+ $builder->add('capacite', IntegerType::class, array(
+ 'label' => "Capacité",
+ 'label_attr' => array(),
+ 'attr' => array(),
+ ));
+ $builder->add('lieu', TextType::class, array(
+ 'label' => "Lieu",
+ 'label_attr' => array(),
+ 'attr' => array(),
+ ));
+ $builder->add('save', SubmitType::class, array(
+ 'label' => 'Enregistrer',
+ ));
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ parent::configureOptions($resolver);
+
+ $resolver->setDefault('data_class', Garage::class);
+ $resolver->setDefault('attr', array('class' => 'garage_type'));
+ }
+
+ public function getBlockPrefix()
+ {
+ return 'garage_bundle_garage_type';
+ }
+}
diff --git a/src/GarageBundle/Form/VoitureType.php b/src/GarageBundle/Form/VoitureType.php
new file mode 100755
index 0000000..d7e5684
--- /dev/null
+++ b/src/GarageBundle/Form/VoitureType.php
@@ -0,0 +1,78 @@
+garageDispo = $options['garageDispo'];
+
+ parent::buildForm($builder, $options);
+
+ $builder->add('marque', TextType::class, array(
+ 'label' => "Marque",
+ ));
+ $builder->add('modele', TextType::class, array(
+ 'label' => "Modèle",
+ ));
+ $builder->add('path', TextType::class, array(
+ 'label' => "Chemin",
+ ));
+ $builder->add('annee', IntegerType::class, array(
+ 'label' => "Année",
+ ));
+ $builder->add('dateAchat', DateTimeType::class, array(
+ 'label' => "Date d'achat",
+ ));
+ $builder->add('prix', MoneyType::class, array(
+ 'label' => "Prix",
+ ));
+ $builder->add('garage', EntityType::class, array(
+ 'label' => "Garage",
+ 'class' => Garage::class,
+ 'query_builder' => function(GarageRepository $repository) {
+ return $repository->findAvailable();
+ },
+ 'choice_label' => 'Nom'
+ ));
+ $builder->add('categorie', EntityType::class, array(
+ 'label' => "Catégorie",
+ 'class' => Categorie::class,
+ 'choice_label' => 'Nom'
+ ));
+ $builder->add('save', SubmitType::class, array(
+ 'label' => 'Enregistrer',
+ ));
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ parent::configureOptions($resolver);
+
+ $resolver->setDefault('data_class', Voiture::class);
+ $resolver->setDefault('attr', array('class' => 'voiture_type'));
+
+ }
+
+ public function getBlockPrefix()
+ {
+ return 'garage_bundle_voiture_type';
+ }
+}
diff --git a/src/GarageBundle/GarageBundle.php b/src/GarageBundle/GarageBundle.php
new file mode 100755
index 0000000..5b4be0c
--- /dev/null
+++ b/src/GarageBundle/GarageBundle.php
@@ -0,0 +1,9 @@
+createQueryBuilder('c');
+ return $qb->getQuery()->getResult();
+
+ }
+
+ /**
+ * @param $id
+ * @return mixed
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ */
+ public function findOneForUpdate($id)
+ {
+ $qb = $this->createQueryBuilder('c')
+ ->where('c.id = :id')
+ ->setParameter(':id', $id);
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+
+
+ /**
+ * @param $id
+ * @return mixed
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ */
+ public function findOneForDelete($id)
+ {
+ $qb = $this->createQueryBuilder('c')
+ ->where('c.id = :id')
+ ->setParameter(':id', $id);
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+
+
+
+}
diff --git a/src/GarageBundle/Repository/GarageRepository.php b/src/GarageBundle/Repository/GarageRepository.php
new file mode 100755
index 0000000..3bafacf
--- /dev/null
+++ b/src/GarageBundle/Repository/GarageRepository.php
@@ -0,0 +1,70 @@
+createQueryBuilder('g');
+ return $qb->getQuery()->getResult();
+
+ }
+
+ /**
+ * @param $id
+ * @return mixed
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ */
+ public function findOneForUpdate($id)
+ {
+ $qb = $this->createQueryBuilder('g')
+ ->where('g.id = :id')
+ ->setParameter(':id', $id);
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+
+
+ /**
+ * @param $id
+ * @return mixed
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ */
+ public function findOneForDelete($id)
+ {
+ $qb = $this->createQueryBuilder('g')
+ ->where('g.id = :id')
+ ->setParameter(':id', $id);
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+
+
+ /**
+ * @param $id
+ * @return array
+ */
+ public function findAvailable()
+ {
+ $qb = $this->createQueryBuilder('g')
+ ->leftJoin('g.voitures', 'v')
+ ->select('g.id, g.nom, g.capacite')
+ ->groupBy('g.id')
+ ->having('count(v.garage) < g.capacite')
+ ;
+ return $qb; // attention ici on retourne une qb !!
+ }
+
+
+}
diff --git a/src/GarageBundle/Repository/VoitureRepository.php b/src/GarageBundle/Repository/VoitureRepository.php
new file mode 100755
index 0000000..bad6441
--- /dev/null
+++ b/src/GarageBundle/Repository/VoitureRepository.php
@@ -0,0 +1,56 @@
+createQueryBuilder('v');
+ return $qb->getQuery()->getResult();
+
+ }
+
+ /**
+ * @param $id
+ * @return mixed
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ */
+ public function findOneForUpdate($id)
+ {
+ $qb = $this->createQueryBuilder('v')
+ ->where('v.id = :id')
+ ->setParameter(':id', $id);
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+
+
+ /**
+ * @param $id
+ * @return mixed
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ */
+ public function findOneForDelete($id)
+ {
+ $qb = $this->createQueryBuilder('v')
+ ->where('v.id = :id')
+ ->setParameter(':id', $id);
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+
+
+
+
+}
diff --git a/src/GarageBundle/Resources/config/routing.yml b/src/GarageBundle/Resources/config/routing.yml
new file mode 100755
index 0000000..0ac3803
--- /dev/null
+++ b/src/GarageBundle/Resources/config/routing.yml
@@ -0,0 +1,97 @@
+garage_homepage:
+ path: /
+ defaults:
+ _controller: GarageBundle:Default:index
+
+## CRUD Garage
+
+garage_create:
+ path: /garage/add
+ defaults:
+ _controller: GarageBundle:Garage:create
+ methods: [ GET, POST ]
+
+garage_read:
+ path: /garages
+ defaults:
+ _controller: GarageBundle:Garage:read
+ methods: [ GET ]
+
+garage_update:
+ path: /garage/edit/{id}
+ requirements:
+ id: \d+
+ defaults:
+ _controller: GarageBundle:Garage:update
+ methods: [ GET, POST ]
+
+garage_delete:
+ path: /garage/delete/{id}
+ requirements:
+ id: \d+
+ defaults:
+ _controller: GarageBundle:Garage:delete
+ methods: [ GET, DELETE ]
+
+
+## CRUD Voiture
+
+garage_voiture_create:
+ path: /voiture/add
+ defaults:
+ _controller: GarageBundle:Voiture:create
+ methods: [ GET, POST ]
+
+garage_voiture_read:
+ path: /voitures
+ defaults:
+ _controller: GarageBundle:Voiture:read
+ methods: [ GET ]
+
+garage_voiture_update:
+ path: /voiture/edit/{id}
+ requirements:
+ id: \d+
+ defaults:
+ _controller: GarageBundle:Voiture:update
+ methods: [ GET, POST ]
+
+garage_voiture_delete:
+ path: /voiture/delete/{id}
+ requirements:
+ id: \d+
+ defaults:
+ _controller: GarageBundle:Voiture:delete
+ methods: [ GET, DELETE ]
+
+
+
+## CRUD Voiture
+
+garage_categorie_create:
+ path: /categorie/add
+ defaults:
+ _controller: GarageBundle:Categorie:create
+ methods: [ GET, POST ]
+
+garage_categorie_read:
+ path: /categories
+ defaults:
+ _controller: GarageBundle:Categorie:read
+ methods: [ GET ]
+
+garage_categorie_update:
+ path: /categorie/edit/{id}
+ requirements:
+ id: \d+
+ defaults:
+ _controller: GarageBundle:Categorie:update
+ methods: [ GET, POST ]
+
+garage_categorie_delete:
+ path: /categorie/delete/{id}
+ requirements:
+ id: \d+
+ defaults:
+ _controller: GarageBundle:Categorie:delete
+ methods: [ GET, DELETE ]
diff --git a/src/GarageBundle/Resources/config/services.yml b/src/GarageBundle/Resources/config/services.yml
new file mode 100755
index 0000000..da5eef8
--- /dev/null
+++ b/src/GarageBundle/Resources/config/services.yml
@@ -0,0 +1,4 @@
+services:
+# garage.example:
+# class: GarageBundle\Example
+# arguments: ["@service_id", "plain_value", "%parameter%"]
diff --git a/src/GarageBundle/Resources/views/Categorie/create.html.twig b/src/GarageBundle/Resources/views/Categorie/create.html.twig
new file mode 100755
index 0000000..0bf9e4a
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Categorie/create.html.twig
@@ -0,0 +1,16 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Nouvelle catégorie
+{% endblock %}
+
+{% block body %}
+ Retour
+ {{ block('title') }}
+
+ {{ form(formCategorie) }}
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
diff --git a/src/GarageBundle/Resources/views/Categorie/read.html.twig b/src/GarageBundle/Resources/views/Categorie/read.html.twig
new file mode 100755
index 0000000..b7654d5
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Categorie/read.html.twig
@@ -0,0 +1,51 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Les catégories
+{% endblock %}
+
+{% block body %}
+ {{ block('title') }}
+
+ {% for label, messages in app.flashes() %}
+ {% for message in messages %}
+
+ {{ message }}
+
+ {% endfor %}
+ {% endfor %}
+
+
+
+
+ #
+ Nom
+ Date création
+ Date Modif
+ Action
+
+
+
+ {% for categorie in categories %}
+
+ {{ categorie.id }}
+ {{ categorie.nom }}
+ {% if categorie.createdAt is not null %}{{ categorie.createdAt|date("m/d/Y H:i") }}{% endif %}
+ {% if categorie.modifiedAt is not null %}{{ categorie.modifiedAt|date("m/d/Y H:i") }}{% endif %}
+
+ Editer
+ Supprimer
+
+
+ {% endfor %}
+
+
+
+
+
+
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
diff --git a/src/GarageBundle/Resources/views/Categorie/update.html.twig b/src/GarageBundle/Resources/views/Categorie/update.html.twig
new file mode 100755
index 0000000..7aa5e83
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Categorie/update.html.twig
@@ -0,0 +1,16 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Modifier une catégorie
+{% endblock %}
+
+{% block body %}
+ Retour
+ {{ block('title') }}
+
+ {{ form(formCategorie) }}
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
diff --git a/src/GarageBundle/Resources/views/Default/footer.html.twig b/src/GarageBundle/Resources/views/Default/footer.html.twig
new file mode 100755
index 0000000..06dfc38
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Default/footer.html.twig
@@ -0,0 +1 @@
+Mathieu Jaumotte 2018
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/Default/index.html.twig b/src/GarageBundle/Resources/views/Default/index.html.twig
new file mode 100755
index 0000000..86f97c3
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Default/index.html.twig
@@ -0,0 +1,74 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Page d'accueil
+{% endblock %}
+
+{% block body %}
+
+ {{ block('title') }}
+ Exercice d'évaluation
+
+
+ Exercice pratique en Symfony 3.4.*
+
+
+
+ Gestion d’une collection de voitures
+
+
+ Il vous est demandé de réaliser le début d’une application web concernant la gestion
+ d’une collection de voitures pour un passionné fortuné.
+
+
+ Le système d’information doit pouvoir créer des garages qui sont caractérisés par un
+ numéro unique, une capacité maximale, un lieu ( uniquement le nom de la ville ). Un
+ garage contient des voitures qui elles sont caractérisées par un numéro de série,
+ une catégorie venant d’une liste, un modèle, une photo ( path ), l’année de
+ construction, une marque, la date d’achat ainsi que le prix. Un garage ayant atteint
+ sa capacité maximale ne peut plus ajouter de voitures. Lors d’un ajout d’une
+ nouvelle voiture, le système doit pouvoir me sortir les garages qui sont disponibles.
+
+
+ Vous devez réaliser :
+
+
+ un nouveau bundle
+ les entités suivantes avec leurs associations
+
+ Garage
+ Voiture
+ Catégorie
+
+
+ les 3 CRUD (create, update et delete)
+ Chaque entité doit avoir 2 champs date
+
+ createdAt avec l’évènement Doctrine PrePersist
+ modifiedAt avec l’évènement Doctrine PreUpdate
+
+
+ les formulaires externalisés avec au minimum le data_class défini
+ Template : création d’un template de base avec héritage dans les vues.
+
+ (NE VOUS TRACASSEZ PAS AVEC LE CSS, C’EST PAS LE BUT)
+
+
+ Dans la page d’accueil, le système doit vous donner les garages avec leurs
+ compositions, afficher une différence s’ils sont complets, permettre d’ajouter des
+ garages, des voitures, des catégories, de pouvoir modifier et supprimer les entités.
+
+
+ Utiliser les messages flash pour notifier les différentes actions. Concernant les
+ images, cherchez-en sur le web ( je vous conseille d’utiliser les outils dans images de
+ Google et de définir la taille en moyenne ).
+
+
+ Bon travail les ami(e)s.
+
+
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
diff --git a/src/GarageBundle/Resources/views/Default/navbar.html.twig b/src/GarageBundle/Resources/views/Default/navbar.html.twig
new file mode 100755
index 0000000..75fdc0e
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Default/navbar.html.twig
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/src/GarageBundle/Resources/views/Garage/create.html.twig b/src/GarageBundle/Resources/views/Garage/create.html.twig
new file mode 100755
index 0000000..70809a9
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Garage/create.html.twig
@@ -0,0 +1,16 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Nouveau Garage
+{% endblock %}
+
+{% block body %}
+ Retour
+ {{ block('title') }}
+
+ {{ form(formGarage) }}
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/Garage/read.html.twig b/src/GarageBundle/Resources/views/Garage/read.html.twig
new file mode 100755
index 0000000..7d737c7
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Garage/read.html.twig
@@ -0,0 +1,57 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Les Garages
+{% endblock %}
+
+{% block body %}
+ {{ block('title') }}
+
+ {% for label, messages in app.flashes() %}
+ {% for message in messages %}
+
+ {{ message }}
+
+ {% endfor %}
+ {% endfor %}
+
+
+
+
+ #
+ Nom
+ Nb Voitures
+ Capacité
+ Lieu
+ Date création
+ Date Modif
+ Action
+
+
+
+ {% for garage in garages %}
+
+ {{ garage.id }}
+ {{ garage.nom }}
+ {{ garage.voitures|length }}
+ {{ garage.capacite }}
+ {{ garage.lieu }}
+ {% if garage.createdAt is not null %}{{ garage.createdAt|date("m/d/Y H:i") }}{% endif %}
+ {% if garage.modifiedAt is not null %}{{ garage.modifiedAt|date("m/d/Y H:i") }}{% endif %}
+
+ Editer
+ Supprimer
+
+
+ {% endfor %}
+
+
+
+
+
+
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/Garage/update.html.twig b/src/GarageBundle/Resources/views/Garage/update.html.twig
new file mode 100755
index 0000000..6ee9639
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Garage/update.html.twig
@@ -0,0 +1,16 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Modifier un Garage
+{% endblock %}
+
+{% block body %}
+ Retour
+ {{ block('title') }}
+
+ {{ form(formGarage) }}
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/Voiture/create.html.twig b/src/GarageBundle/Resources/views/Voiture/create.html.twig
new file mode 100755
index 0000000..1eabc83
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Voiture/create.html.twig
@@ -0,0 +1,16 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Nouvelle voiture
+{% endblock %}
+
+{% block body %}
+ Retour
+ {{ block('title') }}
+
+ {{ form(formVoiture) }}
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/Voiture/read.html.twig b/src/GarageBundle/Resources/views/Voiture/read.html.twig
new file mode 100755
index 0000000..da07c57
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Voiture/read.html.twig
@@ -0,0 +1,61 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Les Voitures
+{% endblock %}
+
+{% block body %}
+ {{ block('title') }}
+
+ {% for label, messages in app.flashes() %}
+ {% for message in messages %}
+
+ {{ message }}
+
+ {% endfor %}
+ {% endfor %}
+
+
+
+
+ #
+ Marque
+ Modèle
+ Image
+ Année
+ Date d'achat
+ Prix
+ Garage
+ Catégorie
+ Action
+
+
+
+ {% for voiture in voitures %}
+
+ {{ voiture.id }}
+ {{ voiture.marque }}
+ {{ voiture.modele }}
+
+ {{ voiture.annee }}
+ {{ voiture.dateAchat|date("m/d/Y") }}
+ {{ voiture.prix }}
+ {{ voiture.garage.nom }}
+ {{ voiture.categorie.nom }}
+
+ Editer
+ Supprimer
+
+
+ {% endfor %}
+
+
+
+
+
+
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/Voiture/update.html.twig b/src/GarageBundle/Resources/views/Voiture/update.html.twig
new file mode 100755
index 0000000..dd9a23f
--- /dev/null
+++ b/src/GarageBundle/Resources/views/Voiture/update.html.twig
@@ -0,0 +1,16 @@
+{% extends '@Garage/layout.html.twig' %}
+
+{% block title %}
+ Modifier une voiture
+{% endblock %}
+
+{% block body %}
+ Retour
+ {{ block('title') }}
+
+ {{ form(formVoiture) }}
+
+{% endblock %}
+
+{% block customJS %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/GarageBundle/Resources/views/layout.html.twig b/src/GarageBundle/Resources/views/layout.html.twig
new file mode 100755
index 0000000..1aa2458
--- /dev/null
+++ b/src/GarageBundle/Resources/views/layout.html.twig
@@ -0,0 +1,55 @@
+{% extends "base.html.twig" %}
+
+{% block title %}
+ GarageBundle
+{% endblock %}
+
+{% block stylesheets %}{% endblock %}
+
+{% block layout %}
+
+
+
+
+ {% block body %}
+
+
{{ block('title') }}
+
+ {% endblock %}
+
+
+
+
+
+
+{% endblock %}
+
+{% block javascripts %}
+
+ {% block customJS %}{% endblock %}
+{% endblock %}
\ No newline at end of file
--
GitLab