소스 검색

Liste des films

François 6 년 전
부모
커밋
081220c040

+ 1 - 1
app/Resources/views/base.html.twig

@@ -2,7 +2,7 @@
 <html>
     <head>
         <meta charset="UTF-8" />
-        <title>{% block title %}Welcome!{% endblock %}</title>
+        <title>{% block title %}VideoPotes{% endblock %}</title>
         {% block stylesheets %}{% endblock %}
         <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
     </head>

+ 1 - 1
app/config/config.yml

@@ -6,7 +6,7 @@ imports:
 # Put parameters here that don't need to change on each machine where the app is deployed
 # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
 parameters:
-    locale: en
+    locale: fr
 
 framework:
     #esi: ~

+ 1 - 0
app/config/security.yml

@@ -15,6 +15,7 @@ security:
 
         main:
             anonymous: ~
+            logout_on_user_change: true
             # activate different ways to authenticate
 
             # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate

+ 55 - 0
src/AppBundle/Controller/VideothequeController.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace AppBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\Routing\Annotation\Route;
+use AppBundle\Entity\Film;
+
+class VideothequeController extends Controller
+{
+    /**
+     * @Route("/liste", name="videotheque_liste")
+     */
+    public function listeAction()
+    {
+	$em = $this->getDoctrine()->getManager();
+	$repo = $em->getRepository('AppBundle:Film');
+	$listeFilms = $repo->findAll();
+
+        return $this->render('@App/videotheque/liste.html.twig', array(
+            'listeFilms'	=>	$listeFilms
+        ));
+    }
+
+    /**
+     * @Route("/ajouter", name="videotheque_ajouter")
+     */
+    public function ajouterAction()
+    {
+        return $this->render('@App/videotheque/ajouter.html.twig', array(
+            // ...
+        ));
+    }
+
+    /**
+     * @Route("/modifier/{id}", name="videotheque_modifier")
+     */
+    public function modifierAction($id)
+    {
+        return $this->render('@App/videotheque/modifier.html.twig', array(
+            // ...
+        ));
+    }
+
+    /**
+     * @Route("/supprimer/{id}", name="videotheque_supprimer")
+     */
+    public function supprimerAction($id)
+    {
+        return $this->render('@App/videotheque/supprimer.html.twig', array(
+            // ...
+        ));
+    }
+
+}

+ 125 - 0
src/AppBundle/Entity/Film.php

@@ -0,0 +1,125 @@
+<?php
+
+namespace AppBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Film
+ *
+ * @ORM\Table(name="film")
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\FilmRepository")
+ */
+class Film
+{
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="titre", type="string", length=255)
+     */
+    private $titre;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="annee", type="date", nullable=true)
+     */
+    private $annee;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Realisateur", inversedBy="films")
+     */
+    private $realisateur;
+
+
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set titre
+     *
+     * @param string $titre
+     *
+     * @return Film
+     */
+    public function setTitre($titre)
+    {
+        $this->titre = $titre;
+
+        return $this;
+    }
+
+    /**
+     * Get titre
+     *
+     * @return string
+     */
+    public function getTitre()
+    {
+        return $this->titre;
+    }
+
+    /**
+     * Set annee
+     *
+     * @param \DateTime $annee
+     *
+     * @return Film
+     */
+    public function setAnnee($annee)
+    {
+        $this->annee = $annee;
+
+        return $this;
+    }
+
+    /**
+     * Get annee
+     *
+     * @return \DateTime
+     */
+    public function getAnnee()
+    {
+        return $this->annee;
+    }
+
+    /**
+     * Set realisateur
+     *
+     * @param \AppBundle\Entity\Realisateur $realisateur
+     *
+     * @return Film
+     */
+    public function setRealisateur(\AppBundle\Entity\Realisateur $realisateur = null)
+    {
+        $this->realisateur = $realisateur;
+
+        return $this;
+    }
+
+    /**
+     * Get realisateur
+     *
+     * @return \AppBundle\Entity\Realisateur
+     */
+    public function getRealisateur()
+    {
+        return $this->realisateur;
+    }
+}

+ 102 - 0
src/AppBundle/Entity/Film.php~

@@ -0,0 +1,102 @@
+<?php
+
+namespace AppBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Film
+ *
+ * @ORM\Table(name="film")
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\FilmRepository")
+ */
+class Film
+{
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="titre", type="string", length=255)
+     */
+    private $titre;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="annee", type="date", nullable=true)
+     */
+    private $annee;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Realisateur", inversedBy="films")
+     */
+    private $realisateur;
+
+
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set titre
+     *
+     * @param string $titre
+     *
+     * @return Film
+     */
+    public function setTitre($titre)
+    {
+        $this->titre = $titre;
+
+        return $this;
+    }
+
+    /**
+     * Get titre
+     *
+     * @return string
+     */
+    public function getTitre()
+    {
+        return $this->titre;
+    }
+
+    /**
+     * Set annee
+     *
+     * @param \DateTime $annee
+     *
+     * @return Film
+     */
+    public function setAnnee($annee)
+    {
+        $this->annee = $annee;
+
+        return $this;
+    }
+
+    /**
+     * Get annee
+     *
+     * @return \DateTime
+     */
+    public function getAnnee()
+    {
+        return $this->annee;
+    }
+}
+

+ 142 - 0
src/AppBundle/Entity/Realisateur.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace AppBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Realisateur
+ *
+ * @ORM\Table(name="realisateur")
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\RealisateurRepository")
+ */
+class Realisateur
+{
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="prenom", type="string", length=255)
+     */
+    private $prenom;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="nom", type="string", length=255)
+     */
+    private $nom;
+
+    /**
+     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Film", mappedBy="realisateur")
+     * @var \Doctrine\Common\Collections\Collection
+     */
+    private $films;
+
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set prenom
+     *
+     * @param string $prenom
+     *
+     * @return Realisateur
+     */
+    public function setPrenom($prenom)
+    {
+        $this->prenom = $prenom;
+
+        return $this;
+    }
+
+    /**
+     * Get prenom
+     *
+     * @return string
+     */
+    public function getPrenom()
+    {
+        return $this->prenom;
+    }
+
+    /**
+     * Set nom
+     *
+     * @param string $nom
+     *
+     * @return Realisateur
+     */
+    public function setNom($nom)
+    {
+        $this->nom = $nom;
+
+        return $this;
+    }
+
+    /**
+     * Get nom
+     *
+     * @return string
+     */
+    public function getNom()
+    {
+        return $this->nom;
+    }
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->films = new \Doctrine\Common\Collections\ArrayCollection();
+    }
+
+    /**
+     * Add film
+     *
+     * @param \AppBundle\Entity\Film $film
+     *
+     * @return Realisateur
+     */
+    public function addFilm(\AppBundle\Entity\Film $film)
+    {
+        $this->films[] = $film;
+
+        return $this;
+    }
+
+    /**
+     * Remove film
+     *
+     * @param \AppBundle\Entity\Film $film
+     */
+    public function removeFilm(\AppBundle\Entity\Film $film)
+    {
+        $this->films->removeElement($film);
+    }
+
+    /**
+     * Get films
+     *
+     * @return \Doctrine\Common\Collections\Collection
+     */
+    public function getFilms()
+    {
+        return $this->films;
+    }
+}

+ 102 - 0
src/AppBundle/Entity/Realisateur.php~

@@ -0,0 +1,102 @@
+<?php
+
+namespace AppBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Realisateur
+ *
+ * @ORM\Table(name="realisateur")
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\RealisateurRepository")
+ */
+class Realisateur
+{
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="prenom", type="string", length=255)
+     */
+    private $prenom;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="nom", type="string", length=255)
+     */
+    private $nom;
+
+    /**
+     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Film", mappedBy="realisateur")
+     * @var \Doctrine\Common\Collections\Collection
+     */
+    private $films;
+
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set prenom
+     *
+     * @param string $prenom
+     *
+     * @return Realisateur
+     */
+    public function setPrenom($prenom)
+    {
+        $this->prenom = $prenom;
+
+        return $this;
+    }
+
+    /**
+     * Get prenom
+     *
+     * @return string
+     */
+    public function getPrenom()
+    {
+        return $this->prenom;
+    }
+
+    /**
+     * Set nom
+     *
+     * @param string $nom
+     *
+     * @return Realisateur
+     */
+    public function setNom($nom)
+    {
+        $this->nom = $nom;
+
+        return $this;
+    }
+
+    /**
+     * Get nom
+     *
+     * @return string
+     */
+    public function getNom()
+    {
+        return $this->nom;
+    }
+}
+

+ 13 - 0
src/AppBundle/Repository/FilmRepository.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace AppBundle\Repository;
+
+/**
+ * FilmRepository
+ *
+ * This class was generated by the Doctrine ORM. Add your own custom
+ * repository methods below.
+ */
+class FilmRepository extends \Doctrine\ORM\EntityRepository
+{
+}

+ 13 - 0
src/AppBundle/Repository/RealisateurRepository.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace AppBundle\Repository;
+
+/**
+ * RealisateurRepository
+ *
+ * This class was generated by the Doctrine ORM. Add your own custom
+ * repository methods below.
+ */
+class RealisateurRepository extends \Doctrine\ORM\EntityRepository
+{
+}

+ 7 - 0
src/AppBundle/Resources/views/videotheque/ajouter.html.twig

@@ -0,0 +1,7 @@
+{% extends "base.html.twig" %}
+
+{% block title %}AppBundle:videotheque:ajouter{% endblock %}
+
+{% block body %}
+<h1>Welcome to the videotheque:ajouter page</h1>
+{% endblock %}

+ 25 - 0
src/AppBundle/Resources/views/videotheque/liste.html.twig

@@ -0,0 +1,25 @@
+{% extends "base.html.twig" %}
+
+{% block title %}Vidéothèque commune{% endblock %}
+
+{% block body %}
+<h1>Bienvenue sur la vidéothèque des potes</h1>
+<table>
+	<thead>
+		<tr>
+			<th>Titre du film</th>
+			<th>Réalisateur</th>
+			<th>Année</th>
+		</tr>
+	</thead>
+	<tbody>
+		{% for film in listeFilms %}
+		<tr>
+			<td>{{ film.titre }}</td>
+			<td>{{ film.realisateur.prenom }} {{ film.realisateur.nom }}</td>
+			<td>{{ film.annee }}</td>
+		</tr>
+		{% endfor %}
+	</tbody>
+</table>
+{% endblock %}

+ 7 - 0
src/AppBundle/Resources/views/videotheque/modifier.html.twig

@@ -0,0 +1,7 @@
+{% extends "base.html.twig" %}
+
+{% block title %}AppBundle:videotheque:modifier{% endblock %}
+
+{% block body %}
+<h1>Welcome to the videotheque:modifier page</h1>
+{% endblock %}

+ 7 - 0
src/AppBundle/Resources/views/videotheque/supprimer.html.twig

@@ -0,0 +1,7 @@
+{% extends "base.html.twig" %}
+
+{% block title %}AppBundle:videotheque:supprimer{% endblock %}
+
+{% block body %}
+<h1>Welcome to the videotheque:supprimer page</h1>
+{% endblock %}

+ 37 - 0
src/AppBundle/Tests/Controller/videothequeControllerTest.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace AppBundle\Tests\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+
+class videothequeControllerTest extends WebTestCase
+{
+    public function testListe()
+    {
+        $client = static::createClient();
+
+        $crawler = $client->request('GET', '/liste');
+    }
+
+    public function testAjouter()
+    {
+        $client = static::createClient();
+
+        $crawler = $client->request('GET', '/ajouter');
+    }
+
+    public function testModifier()
+    {
+        $client = static::createClient();
+
+        $crawler = $client->request('GET', '/modifier');
+    }
+
+    public function testSupprimer()
+    {
+        $client = static::createClient();
+
+        $crawler = $client->request('GET', '/supprimer');
+    }
+
+}