Skip to content

Instantly share code, notes, and snippets.

@faboo03
Created January 12, 2016 20:46
Show Gist options
  • Save faboo03/57cbaeeabe60cc3f1a99 to your computer and use it in GitHub Desktop.
Save faboo03/57cbaeeabe60cc3f1a99 to your computer and use it in GitHub Desktop.
Hello!
<h1 id="symfony-2-tp-anonymousgift">Symfony 2 : TP AnonymousGift</h1>
<h2 id="sommaire">Sommaire</h2>
<ul>
<li>Présentation du contexte</li>
<li>Analyse UML <br>
<ul><li>Flow</li>
<li>Entités <br>
<ul><li>User</li>
<li>Group</li>
<li>Gifts</li></ul></li></ul></li>
<li>Installation de SF2 <br>
<ul><li>Composer install</li>
<li>Installation du vHost</li></ul></li>
<li>Création du modèle de donnée <br>
<ul><li>Entities</li>
<li>Génération de la BDD</li></ul></li>
<li>US Stories</li>
<li>Consigne autre + aide supplémentaire</li>
</ul>
<hr>
<h2 id="contexte">Contexte</h2>
<p>Nous allons créer un site qui nous permet de créer un évènement, d’inviter des amis et de tous arriver avec 1 cadeau et de repartir avec un autre cadeau. </p>
<p>Le principe est donc simple, il y a un administrateur qui créé un évènement et qui invite des amis par email. </p>
<p>Les gens reçoivent le mail avec un lien et s’inscrivent à l’évènement. Une fois que l’on a rassemblé tout le monde, on fait passer un algorithme qui répartie les personnes aléatoirement et qui s’assurent qu’il n’y a bien qu’une seule boucle, pour éviter que 2 personnes s’offre mutuellement un cadeau. </p>
<p>On ajoutera aussi un petit formulaire pour aider la personne qui recevra notre nom, à choisir un cadeau qui nous fera plaisir. </p>
<blockquote>
<p><strong>Remarque:</strong> <br>
Toute idée bonus sera bonne à prendre. </p>
</blockquote>
<h2 id="analyse-uml">Analyse UML</h2>
<h4 id="cycle-de-vie">Cycle de vie</h4>
<div class="flow-chart"><svg height="1345.640625" version="1.1" width="331.65625" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative; top: -0.9375px;"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.2</desc><defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><marker id="raphael-marker-endblock33-obj915" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj916" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj917" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj918" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj919" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj920" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj922" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj924" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock33-obj925" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker></defs><rect x="0" y="0" width="51.03125" height="39" rx="20" ry="20" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="st" transform="matrix(1,0,0,1,128.8125,59.6641)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="stt" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,128.8125,59.6641)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Start</tspan></text><rect x="0" y="0" width="181.234375" height="39" rx="0" ry="0" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="inscription" transform="matrix(1,0,0,1,63.7109,208.3281)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="inscriptiont" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,63.7109,208.3281)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Inscription de l'utilisateur</tspan></text><rect x="0" y="0" width="212.0625" height="39" rx="0" ry="0" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="createAccount" transform="matrix(1,0,0,1,48.2969,356.9922)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="createAccountt" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,48.2969,356.9922)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Création du compte utilisateur</tspan></text><rect x="0" y="0" width="174.046875" height="39" rx="0" ry="0" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="createEvent" transform="matrix(1,0,0,1,67.3047,505.6563)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="createEventt" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,67.3047,505.6563)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Création de l'évènement</tspan></text><rect x="0" y="0" width="201.21875" height="39" rx="0" ry="0" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="invitFriends" transform="matrix(1,0,0,1,53.7188,654.3203)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="invitFriendst" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,53.7188,654.3203)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Invitation des amis par email</tspan></text><path fill="#ffffff" stroke="#000000" d="M75.1640625,37.58203125L0,75.1640625L150.328125,150.328125L300.65625,75.1640625L150.328125,0L0,75.1640625" stroke-width="2" font-family="sans-serif" font-weight="normal" id="launchReady" class="flowchart" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;" transform="matrix(1,0,0,1,4,747.3203)"></path><text x="80.1640625" y="75.1640625" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="launchReadyt" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,4,747.3203)"><tspan dy="5.5078125" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Tous les invités ont validé ?</tspan></text><rect x="0" y="0" width="178.046875" height="39" rx="0" ry="0" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="algoOk" transform="matrix(1,0,0,1,65.3047,1007.3125)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="algoOkt" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,65.3047,1007.3125)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Création de la répartition</tspan></text><rect x="0" y="0" width="241.75" height="39" rx="0" ry="0" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="notifEmail" transform="matrix(1,0,0,1,33.4531,1155.9766)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="notifEmailt" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,33.4531,1155.9766)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Envoi d'un email avec la répartition</tspan><tspan dy="18" x="10" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></tspan></text><rect x="0" y="0" width="44.421875" height="39" rx="20" ry="20" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" stroke-width="2" class="flowchart" id="e" transform="matrix(1,0,0,1,132.1172,1304.6406)"></rect><text x="10" y="19.5" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" id="et" class="flowchartt" font-weight="normal" transform="matrix(1,0,0,1,132.1172,1304.6406)"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">End</tspan></text><path fill="none" stroke="#000000" d="M154.328125,98.6640625C154.328125,98.6640625,154.328125,187.71377562591806,154.328125,205.32370424701026" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj915)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><path fill="none" stroke="#000000" d="M154.328125,247.328125C154.328125,247.328125,154.328125,336.37783812591806,154.328125,353.98776674701026" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj916)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><path fill="none" stroke="#000000" d="M154.328125,395.9921875C154.328125,395.9921875,154.328125,485.04190062591806,154.328125,502.65182924701026" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj917)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><path fill="none" stroke="#000000" d="M154.328125,544.65625C154.328125,544.65625,154.328125,633.7059631259181,154.328125,651.3158917470103" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj918)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><path fill="none" stroke="#000000" d="M154.328125,693.3203125C154.328125,693.3203125,154.328125,732.9744124412537,154.328125,744.3207515846007" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj919)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><path fill="none" stroke="#000000" d="M154.328125,897.6484375C154.328125,897.6484375,154.328125,986.6981506259181,154.328125,1004.3080792470103" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj920)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><text x="159.328125" y="907.6484375" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" font-weight="normal"><tspan dy="5.5078125" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">yes</tspan></text><path fill="none" stroke="#000000" d="M304.65625,822.484375C304.65625,822.484375,329.65625,822.484375,329.65625,822.484375C329.65625,822.484375,329.65625,629.3203125,329.65625,629.3203125C329.65625,629.3203125,154.328125,629.3203125,154.328125,629.3203125C154.328125,629.3203125,154.328125,644.6937570571899,154.328125,651.3295602742583" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj922)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><text x="309.65625" y="812.484375" text-anchor="start" font-family="sans-serif" font-size="14px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-family: sans-serif; font-size: 14px; font-weight: normal;" font-weight="normal"><tspan dy="5.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">no</tspan></text><path fill="none" stroke="#000000" d="M154.328125,1046.3125C154.328125,1046.3125,154.328125,1135.362213125918,154.328125,1152.9721417470103" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj924)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path><path fill="none" stroke="#000000" d="M154.328125,1194.9765625C154.328125,1194.9765625,154.328125,1284.026275625918,154.328125,1301.6362042470103" stroke-width="2" marker-end="url(#raphael-marker-endblock33-obj925)" font-family="sans-serif" font-weight="normal" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: sans-serif; font-weight: normal;"></path></svg></div>
<h4 id="modèle-de-donnée">Modèle de donnée</h4>
<ul>
<li>User <br>
<ul><li>lastname (string) </li>
<li>firstname (string)</li>
<li>email (string)</li></ul></li>
<li>Event <br>
<ul><li>startdate (datetime)</li>
<li>name (string)</li>
<li>owner (user)</li>
<li>token (string)</li>
<li>is_distributed (boolean)</li>
<li>shared_token (string)</li></ul></li>
<li>UserEvent <br>
<ul><li>user (user)</li>
<li>event (event)</li>
<li>received_user (user) // Utilisateur a qui on doit offrir un cadeau</li>
*</ul></li>
</ul>
<h2 id="création-du-projet">Création du projet</h2>
<h3 id="1-installation-de-sf2">1. Installation de SF2</h3>
<p>On commence par installer SF2 en utilisant Composer (ou autre)</p>
<pre class="prettyprint"><code class="language-shell hljs lasso">$ php composer<span class="hljs-built_in">.</span>phar create<span class="hljs-attribute">-project</span> symfony/framework<span class="hljs-attribute">-standard</span><span class="hljs-attribute">-edition</span> anonymous<span class="hljs-attribute">-gift</span> <span class="hljs-string">"2.8.*"</span></code></pre>
<p>On ferra attention à bien préciser une base de donnée qui s’appelle anonymous-gift et de spécifier un utilisateur mysql qui a les droits suffisants pour se connecter à la BDD. </p>
<h3 id="2-installation-du-vhost">2. Installation du vHost</h3>
<pre class="prettyprint"><code class="language-shell hljs apache"><span class="hljs-comment">## /etc/apache2/sites-available/anonymous-gift.conf</span>
<span class="hljs-tag">&lt;VirtualHost *:80&gt;</span>
<span class="hljs-keyword"><span class="hljs-common">ServerName</span></span> anonymous-gift.local
<span class="hljs-keyword"><span class="hljs-common">DocumentRoot</span></span> /home/fabien/workspace/anonymous-gift/web
<span class="hljs-tag">&lt;Directory /home/fabien/workspace/anonymous-gift/web&gt;</span>
<span class="hljs-keyword">AllowOverride</span> <span class="hljs-literal">All</span>
<span class="hljs-keyword">Require</span> <span class="hljs-literal">all</span> granted
<span class="hljs-tag">&lt;/Directory&gt;</span>
<span class="hljs-tag">&lt;/VirtualHost&gt;</span></code></pre>
<p>N’oubliez pas le vhost local</p>
<pre class="prettyprint"><code class="language-shell hljs vala"><span class="hljs-preprocessor">## /etc/hosts</span>
<span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> anonymous-gift.local</code></pre>
<h3 id="3-création-dun-nouveau-bundle">3. Création d’un nouveau bundle</h3>
<pre class="prettyprint"><code class="language-shell hljs vhdl">$ php app/console <span class="hljs-keyword">generate</span>:bundle <span class="hljs-comment">--namespace=Acme/Bundle/BlogBundle</span></code></pre>
<h3 id="4-création-des-entités">4. Création des entités</h3>
<p>On crée les entités dans notre nouveau bundle dans le dossier Entity en suivant le modèle de donnée donné plus haut. </p>
<pre class="prettyprint"><code class="language-shell hljs vhdl">$ php app/console <span class="hljs-keyword">generate</span>:doctrine:<span class="hljs-keyword">entity</span></code></pre>
<p>On créé notre base de donnée et on met à jour le modèle de donnée avec les commandes suivantes : </p>
<pre class="prettyprint"><code class="language-shell hljs ruby"><span class="hljs-variable">$ </span>php app/console <span class="hljs-symbol">doctrine:</span><span class="hljs-symbol">generate:</span>database
<span class="hljs-variable">$ </span>php app/console <span class="hljs-symbol">doctrine:</span><span class="hljs-symbol">schema:</span>update --force</code></pre>
<h3 id="5-user-stories">5. User stories</h3>
<blockquote>
<h4 id="us-0-la-page-home">US-0 : La page Home</h4>
<p>En tant que visiteur, je veux me rendre sur la HomePage afin de me connecter, créer un compte et afficher de bref information sur notre site. </p>
</blockquote>
<p>On va créer une page HTML très simple, avec un petit descriptif, un lien connexion et un lien nous permettant de nous créer un nouveau compte. </p>
<blockquote>
<h4 id="us-1-la-connexion">US-1 : La connexion</h4>
<p>En tant que visiteur je veux créer un compte afin d’accéder à la partie connecté de l’application.</p>
</blockquote>
<ul>
<li>On commence par installer le <a href="https://github.com/FriendsOfSymfony/FOSUserBundle">FOSUserBundle</a> afin de gérer la connexion à notre base application.</li>
<li>On validera que l’on peut utiliser la route <code>/register</code> pour créer un compte.</li>
<li>Attention, il faudra surement mettre à jour la base de donnée, afin de ne pas perdre nos données en permanence, on installera le [DoctrineFixtureBundle] <br>
(<a href="http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html">http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html</a>) et on créera une fixture avec un utilisateur (user / user) qui nous servira d’utilisateur de base.</li>
<li>Après la connexion, on redirige l’utilisateur sur le listing de ses évènements. </li>
</ul>
<blockquote>
<h4 id="us-2-listing-évènement">US-2 : Listing évènement</h4>
<p>En tant qu’utilisateur, lorsque je me connecte, je suis redirigé sur une page qui liste mes évènements en cours ou futur. </p>
</blockquote>
<ul>
<li>On crée une page qui liste simplement les évènements qui ont une date StartDate plus grande que maintenant. </li>
<li>Au pied de cette page, on aura un lien “Ajouter un évènement” afin de permettre à l’utilisateur de créer un évènement. </li>
</ul>
<blockquote>
<h4 id="us-3-création-dun-évènement">US-3 : Création d’un évènement.</h4>
<p>En tant qu’utilisateur, je veux afficher un formulaire afin de créer un nouvel évènement. </p>
</blockquote>
<ul>
<li>On créé un nouveau Type qui contient les champs suivants, autour de l’entité Event <br>
<ul><li>startDate (datetime) </li>
<li>name (string)</li></ul></li>
<li>On crée une nouvelle page, qui affiche le formulaire et qui permet de le valider dans le même controller. </li>
<li>On utilisera <a href="https://github.com/stof/StofDoctrineExtensionsBundle">DoctrineExtension</a> pour s’assurer de générer un token unique <code>md5(timestamp().rand(0,999999))</code> lors d’un PrePersist. De même pour le shared_token. </li>
<li>On ajoutera un évènement <code>PRE_SET_DATA</code> pour s’assurer de bien lier notre nouvel évènement à l’utilisateur connecté. </li>
</ul>
<blockquote>
<h4 id="us-4-page-de-lévènement">US-4 : Page de l’évènement</h4>
<p>En tant qu’utilisateur, je veux pouvoir afficher la page d’un évènement</p>
</blockquote>
<ul>
<li>On créé une page pour afficher l’évènement qui comprendra : <br>
<ul><li>Une liste des personnes qui participent déjà à l’évènement</li>
<li>Un bouton pour ajouter de nouveaux participants</li>
<li>Si je suis l’owner de l’évènement, un bouton pour répartir les personnes. </li></ul></li>
</ul>
<blockquote>
<h4 id="us-5-invitation-des-amis">US-5 : Invitation des amis</h4>
<p>En tant qu’utilisateur, une fois que mon évènement est créé, je veux inviter mes amis à rejoindre la plateforme par email.</p>
</blockquote>
<ul>
<li>On créé un nouveau Type qui aura les champs suivants : <br>
<ul><li>Adresse email</li>
<li>Message</li></ul></li>
<li>On créé une page qui contiendra : <br>
<ul><li>le message suivant : “Votre évènement a bien été créé. Partagez le lien suivant {url(‘event_shared_url’, {“shared_token” : shared_token}, true)} au près de vos amis pour les inviter à vous rejoindre. </li>
<li>Le nouveau formulaire pour notifier les amis, avec comme message par défault, le texte suivant : “Votre ami {firstname} {lastname}, vous invite à le rejoindre sur anonymous-gift.local en cliquant sur le lien suivant : {path(‘event_shared_url’, {“shared_token” : shared_token}, true)}”</li></ul></li>
<li>La validation du formulaire se fait dans le même controller que l’affichage du formulaire. Si le formulaire est valide, on récupère les informations de ce formulaire et <a href="http://symfony.com/doc/current/cookbook/email/email.html">on envoie un mail</a> à l’adresse email avec le message fourni. On ajoute un flash message pour dire que l’invitation est bien parti, et on laisse l’utilisateur envoyer un nouvel email. </li>
</ul>
<blockquote>
<h4 id="us-6-participation-à-un-évènement">US-6 : Participation à un évènement</h4>
<p>En tant qu’utilisateur, lorsque j’ai cliqué sur le lien et que je suis connecté, je suis ajouté à la liste des participants de l’évènement. </p>
</blockquote>
<ul>
<li>On créé une route /event/{shared_token} qui pointe vers un controller specifique. </li>
<li>Dans ce dernier, on récupère l’utilisateur connecté, on récupère l’évènement lié à la route, et on créé un UserEvent qui contient les deux.</li>
<li>Une fois que l’on a créé le UserEvent, on redirige l’utilisateur sur la page de l’évènement</li>
</ul>
<blockquote>
<h4 id="us-7-génération-de-lalgorithme-de-répartition">US-7 : Génération de l’algorithme de répartition</h4>
<p>En tant qu’utilisateur, lorsque je suis le créateur d’un évènement, je peux lancer la génération de la répartition. </p>
</blockquote>
<ul>
<li>On créé une nouvelle classe qui implémente un algorithme très simple <br>
<ul><li>On prend tous les participants</li>
<li>On garde le premier en mémoire</li>
<li>On prend un utilisateur au hasard dans les autres</li>
<li>On assigne cette personne au premier</li>
<li>On recommence jusqu’au dernier qui lui prendra le premier. </li></ul></li>
<li>On créé une nouvelle route, vers un controlleur spécifique qui fait appelle à notre algorithme. </li>
<li>On récupère tous les UserEvent qui auront été mis à jour et on envoie un simple mail à tous avec le nom de la personne qui leur est attribué. </li>
</ul>
<h2 id="consigne-bonus">Consigne Bonus</h2>
<ul>
<li>Utilisez un repos Git pour sauvegarder votre travail et revenir en arrière si besoin. </li>
<li>Utilisez des Fixtures tout au long de votre développement pour permettre de relancer aussi les infos que vous voulez. </li>
<li>N’hésitez pas à utiliser les tests unitaires pour vous assurer que votre application fonctionne bien. Il devrait être écrit en amont du traitement de chaque US. </li>
<li>Prenez les US les unes à la suite des autres, mais en ayant quand même conscience de tout ce que vous avez à faire. Si vous voyez que vous avez besoin d’un élément, mais qu’il sera traité dans une autre US, ne mettez en place que le strict minimum pour vous permettre de passer la US. </li>
*
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment