소스 검색

Merge branch 'clement-dm-rt-at_suite' into 'master'

Clement dm rt at suite

See merge request clement.krebs/twyrael!10
KREBS-CHEVRESSON CLEMENT 4 년 전
부모
커밋
d5b2021418

+ 40 - 2
src/Controller/HomeController.php

@@ -4,6 +4,7 @@ namespace App\Controller;
 
 use App\Entity\Hashtag;
 use App\Entity\Message;
+use App\Entity\Retweets;
 use App\Entity\User;
 use Doctrine\DBAL\Types\TextType;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -11,15 +12,16 @@ use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\Session\Session;
 use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Validator\Constraints\Date;
 
 class HomeController extends AbstractController
 {
     private function cmp_array($a, $b): int
     {
-        if ($a == $b) {
+        if ($a->getDate() == $b->getDate()) {
             return 0;
         }
-        return ($a > $b) ? -1 : 1;
+        return ($a->getDate() > $b->getDate()) ? -1 : 1;
     }
 
     #[Route('/home', name: 'home')]
@@ -84,8 +86,24 @@ class HomeController extends AbstractController
         $em = $this->getDoctrine()->getManager();
         $repository_profile = $em->getRepository(User::class);
         $profile = $repository_profile->findOneBy(array('username' => $session->get('user')));
+        $mentioned_messages = $profile->getMentionedMessages();
         $subscriptions = $profile->getSubscriptions();
+        $rt = $profile->getRetweets();
         $sub_msg = array();
+        foreach ($rt as $r) {
+            $og_message = $r->getOgMessage();
+            $rt_message = new Message();
+            $rt_message->setText($og_message->getText());
+            $rt_message->setSender($og_message->getSender());
+            $rt_message->setId($og_message->getId());
+            $rt_message->setDate($r->getRtDate());
+            array_push($sub_msg, $rt_message);
+        }
+        foreach ($mentioned_messages as $msg_m) {
+            if (!in_array($msg_m->getSender(), $subscriptions->getValues())) {
+                array_push($sub_msg, $msg_m);
+            }
+        }
         foreach ($profile->getMessages() as $msg_u) {
             array_push($sub_msg, $msg_u);
         }
@@ -106,4 +124,24 @@ class HomeController extends AbstractController
             'username' => $session->get('user'),
         ]);
     }
+
+    #[Route('/rt/{msgId}', name: 'rt_message')]
+    public function retweet($msgId) {
+        $session = $this->get('session');
+
+        if (null === $session->get('user')) {
+            return  $this->redirectToRoute('home');
+        }
+        $em = $this->getDoctrine()->getManager();
+        $repository_profile = $em->getRepository(User::class);
+        $profile = $repository_profile->findOneBy(array('username' => $session->get('user')));
+        $repository_message = $em->getRepository(Message::class);
+        $rt = new Retweets();
+        $rt->setRtDate(new \DateTime("now"));
+        $rt->setRetweeter($profile);
+        $rt->setOgMessage($repository_message->find($msgId));
+        $em->persist($rt);
+        $em->flush();
+        return  $this->redirectToRoute('home');
+    }
 }

+ 53 - 0
src/Controller/PrivateDiscussionController.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Controller;
+
+use App\Entity\PrivateDiscussion;
+use App\Entity\PrivateMessage;
+use App\Entity\User;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
+
+class PrivateDiscussionController extends AbstractController
+{
+    #[Route('/private/discussion/{id}', name: 'private_discussion')]
+    public function index($id, Request $request): Response
+    {
+        $session = $this->get('session');
+
+        if (null === $session->get('user')) {
+            return  $this->redirectToRoute('home');
+        }
+
+        $formBuilder = $this->createFormBuilder();
+        $formBuilder->add('text', \Symfony\Component\Form\Extension\Core\Type\TextType::class)
+            ->setAction($this->generateUrl('private_discussion', ['id' => $id]));
+        $form = $formBuilder->getForm();
+
+        $em = $this->getDoctrine()->getManager();
+        $repo_pd = $em->getRepository(PrivateDiscussion::class);
+        $pd = $repo_pd->find($id);
+        $messages = $pd->getPrivateMessages();
+
+        if ($request->getMethod() == 'POST') {
+            $form->handleRequest($request);
+            if($form->isValid()) {
+                $user = $em->getRepository(User::class)->findOneBy(array('username' => $session->get('user')));
+                $pm = new PrivateMessage();
+                $pm->setText($form->get('text')->getData());
+                $pm->setSender($user);
+                $pm->setPrivateDiscussion($pd);
+                $em->persist($pm);
+                $em->flush();
+            }
+        }
+
+        return $this->render('private_discussion/index.html.twig', [
+            'controller_name' => 'PrivateDiscussionController',
+            'messages' => $messages,
+            'form' => $form->createView()
+        ]);
+    }
+}

+ 79 - 0
src/Controller/PrivateDiscussionsController.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace App\Controller;
+
+use App\Entity\PrivateDiscussion;
+use App\Entity\PrivateMessage;
+use App\Entity\User;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
+
+class PrivateDiscussionsController extends AbstractController
+{
+    #[Route('/private/discussions', name: 'private_discussions')]
+    public function index(Request $request): Response
+    {
+        $session = $this->get('session');
+
+        if (null === $session->get('user')) {
+            return  $this->redirectToRoute('home');
+        }
+        $formBuilder = $this->createFormBuilder();
+        $formBuilder->add('text', \Symfony\Component\Form\Extension\Core\Type\TextType::class)
+            ->add('username', \Symfony\Component\Form\Extension\Core\Type\TextType::class)
+            ->setAction($this->generateUrl('private_discussions'));
+        $form = $formBuilder->getForm();
+
+        $em = $this->getDoctrine()->getManager();
+        $repo_user = $em->getRepository(User::class);
+        $user = $repo_user->findOneBy(array('username' => $session->get("user")));
+        $private_discussions = array();
+        foreach ($user->getPrivateDiscussions() as $pd) {
+            $participants = $pd->getParticipants();
+            if ($participants[0] == $user) {
+                $participant = $participants[1];
+            } else {
+                $participant = $participants[0];
+            }
+            array_push($private_discussions, array($pd->getId() => $participant->getUsername()));
+        }
+
+        if ($request->getMethod() == 'POST') {
+            $form->handleRequest($request);
+            if ($form->isValid()) {
+                $recept = $repo_user->findOneBy(array('username' => $form->get('username')->getData()));
+                if (!$recept) {
+                    return new Response("Profil non existant");
+                }
+                $disc_found = false;
+                foreach ($user->getPrivateDiscussions() as $disc) {
+                    if(in_array($recept, $disc->getParticipants()->getValues())) {
+                        $disc_found = true;
+                        break;
+                    }
+                }
+                if ($disc_found) {
+                    return new Response("Discussion existante");
+                }
+                $discussion = new PrivateDiscussion();
+                $discussion->addParticipant($user);
+                $discussion->addParticipant($recept);
+                $dm = new PrivateMessage();
+                $dm->setSender($user);
+                $dm->setText($form->get('text')->getData());
+                $discussion->addPrivateMessage($dm);
+                $em->persist($dm);
+                $em->persist($discussion);
+                $em->flush();
+            }
+        }
+
+        return $this->render('private_discussions/index.html.twig', [
+            'controller_name' => 'PrivateDiscussionsController',
+            'form' => $form->createView(),
+            'private_discussions' => $private_discussions
+        ]);
+    }
+}

+ 13 - 2
src/Controller/ProfileController.php

@@ -2,6 +2,7 @@
 
 namespace App\Controller;
 
+use App\Entity\Message;
 use App\Entity\User;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Response;
@@ -12,10 +13,10 @@ class ProfileController extends AbstractController
 {
     private function cmp_array($a, $b): int
     {
-        if ($a == $b) {
+        if ($a->getDate() == $b->getDate()) {
             return 0;
         }
-        return ($a > $b) ? -1 : 1;
+        return ($a->getDate() > $b->getDate()) ? -1 : 1;
     }
 
     #[Route('/profile/{username}', name: 'profile')]
@@ -55,6 +56,16 @@ class ProfileController extends AbstractController
 
         // Récupération des messages de l'utilisateur
         $sub_msg = array();
+        $rt = $profile->getRetweets();
+        foreach ($rt as $r) {
+            $og_message = $r->getOgMessage();
+            $rt_message = new Message();
+            $rt_message->setText($og_message->getText());
+            $rt_message->setSender($og_message->getSender());
+            $rt_message->setId($og_message->getId());
+            $rt_message->setDate($r->getRtDate());
+            array_push($sub_msg, $rt_message);
+        }
         foreach ($profile->getMessages() as $msg_u) {
             array_push($sub_msg, $msg_u);
         }

+ 41 - 1
src/Entity/Message.php

@@ -31,7 +31,7 @@ class Message
     private $sender;
 
     /**
-     * @ORM\ManyToMany(targetEntity=User::class)
+     * @ORM\ManyToMany(targetEntity=User::class, inversedBy="mentionedMessages")
      */
     private $mentions;
 
@@ -40,9 +40,15 @@ class Message
      */
     private $date;
 
+    /**
+     * @ORM\OneToMany(targetEntity=Retweets::class, mappedBy="ogMessage", orphanRemoval=true)
+     */
+    private $retweets;
+
     public function __construct()
     {
         $this->mentions = new ArrayCollection();
+        $this->retweets = new ArrayCollection();
     }
 
     public function getId(): ?int
@@ -50,6 +56,10 @@ class Message
         return $this->id;
     }
 
+    public function setId($id) {
+        $this->id = $id;
+    }
+
     public function getText(): ?string
     {
         return $this->text;
@@ -109,4 +119,34 @@ class Message
 
         return $this;
     }
+
+    /**
+     * @return Collection|Retweets[]
+     */
+    public function getRetweets(): Collection
+    {
+        return $this->retweets;
+    }
+
+    public function addRetweet(Retweets $retweet): self
+    {
+        if (!$this->retweets->contains($retweet)) {
+            $this->retweets[] = $retweet;
+            $retweet->setOgMessage($this);
+        }
+
+        return $this;
+    }
+
+    public function removeRetweet(Retweets $retweet): self
+    {
+        if ($this->retweets->removeElement($retweet)) {
+            // set the owning side to null (unless already changed)
+            if ($retweet->getOgMessage() === $this) {
+                $retweet->setOgMessage(null);
+            }
+        }
+
+        return $this;
+    }
 }

+ 96 - 0
src/Entity/PrivateDiscussion.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace App\Entity;
+
+use App\Repository\PrivateDiscussionRepository;
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity(repositoryClass=PrivateDiscussionRepository::class)
+ */
+class PrivateDiscussion
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToMany(targetEntity=User::class, inversedBy="privateDiscussions")
+     */
+    private $participants;
+
+    /**
+     * @ORM\OneToMany(targetEntity=PrivateMessage::class, mappedBy="privateDiscussion", orphanRemoval=true)
+     */
+    private $privateMessages;
+
+    public function __construct()
+    {
+        $this->participants = new ArrayCollection();
+        $this->privateMessages = new ArrayCollection();
+    }
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    /**
+     * @return Collection|User[]
+     */
+    public function getParticipants(): Collection
+    {
+        return $this->participants;
+    }
+
+    public function addParticipant(User $participant): self
+    {
+        if (!$this->participants->contains($participant)) {
+            $this->participants[] = $participant;
+        }
+
+        return $this;
+    }
+
+    public function removeParticipant(User $participant): self
+    {
+        $this->participants->removeElement($participant);
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|PrivateMessage[]
+     */
+    public function getPrivateMessages(): Collection
+    {
+        return $this->privateMessages;
+    }
+
+    public function addPrivateMessage(PrivateMessage $privateMessage): self
+    {
+        if (!$this->privateMessages->contains($privateMessage)) {
+            $this->privateMessages[] = $privateMessage;
+            $privateMessage->setPrivateDiscussion($this);
+        }
+
+        return $this;
+    }
+
+    public function removePrivateMessage(PrivateMessage $privateMessage): self
+    {
+        if ($this->privateMessages->removeElement($privateMessage)) {
+            // set the owning side to null (unless already changed)
+            if ($privateMessage->getPrivateDiscussion() === $this) {
+                $privateMessage->setPrivateDiscussion(null);
+            }
+        }
+
+        return $this;
+    }
+}

+ 77 - 0
src/Entity/PrivateMessage.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace App\Entity;
+
+use App\Repository\PrivateMessageRepository;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity(repositoryClass=PrivateMessageRepository::class)
+ */
+class PrivateMessage
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(type="string", length=255)
+     */
+    private $text;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=PrivateDiscussion::class, inversedBy="privateMessages")
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $privateDiscussion;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=User::class, inversedBy="privateMessages")
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $sender;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getText(): ?string
+    {
+        return $this->text;
+    }
+
+    public function setText(string $text): self
+    {
+        $this->text = $text;
+
+        return $this;
+    }
+
+    public function getPrivateDiscussion(): ?PrivateDiscussion
+    {
+        return $this->privateDiscussion;
+    }
+
+    public function setPrivateDiscussion(?PrivateDiscussion $privateDiscussion): self
+    {
+        $this->privateDiscussion = $privateDiscussion;
+
+        return $this;
+    }
+
+    public function getSender(): ?User
+    {
+        return $this->sender;
+    }
+
+    public function setSender(?User $sender): self
+    {
+        $this->sender = $sender;
+
+        return $this;
+    }
+}

+ 85 - 0
src/Entity/Retweets.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Entity;
+
+use App\Repository\RetweetsRepository;
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity(repositoryClass=RetweetsRepository::class)
+ */
+class Retweets
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(type="datetime")
+     */
+    private $rtDate;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=User::class, inversedBy="retweets")
+     */
+    private $retweeter;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=Message::class, inversedBy="retweets")
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $ogMessage;
+
+    public function __construct()
+    {
+    }
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getRtDate(): ?\DateTimeInterface
+    {
+        return $this->rtDate;
+    }
+
+    public function setRtDate(\DateTimeInterface $rtDate): self
+    {
+        $this->rtDate = $rtDate;
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|User[]
+     */
+    public function getRetweeter(): ?User
+    {
+        return $this->retweeter;
+    }
+
+    public function setRetweeter(User $retweeter): self
+    {
+        $this->retweeter = $retweeter;
+
+        return $this;
+    }
+
+    public function getOgMessage(): ?Message
+    {
+        return $this->ogMessage;
+    }
+
+    public function setOgMessage(?Message $ogMessage): self
+    {
+        $this->ogMessage = $ogMessage;
+
+        return $this;
+    }
+}

+ 135 - 0
src/Entity/User.php

@@ -63,12 +63,36 @@ class User implements UserInterface
      */
     private $description;
 
+    /**
+     * @ORM\ManyToMany(targetEntity=Message::class, mappedBy="mentions")
+     */
+    private $mentionedMessages;
+
+    /**
+     * @ORM\OneToMany(targetEntity=Retweets::class, mappedBy="retweeter")
+     */
+    private $retweets;
+
+    /**
+     * @ORM\ManyToMany(targetEntity=PrivateDiscussion::class, mappedBy="participants")
+     */
+    private $privateDiscussions;
+
+    /**
+     * @ORM\OneToMany(targetEntity=PrivateMessage::class, mappedBy="sender", orphanRemoval=true)
+     */
+    private $privateMessages;
+
     public function __construct()
     {
         $this->blockedUsers = new ArrayCollection();
         $this->messages = new ArrayCollection();
         $this->followers = new ArrayCollection();
         $this->subscriptions = new ArrayCollection();
+        $this->mentionedMessages = new ArrayCollection();
+        $this->retweets = new ArrayCollection();
+        $this->privateDiscussions = new ArrayCollection();
+        $this->privateMessages = new ArrayCollection();
     }
 
     public function getId(): ?int
@@ -240,4 +264,115 @@ class User implements UserInterface
     {
         // TODO: Implement eraseCredentials() method.
     }
+
+    /**
+     * @return Collection|Message[]
+     */
+    public function getMentionedMessages(): Collection
+    {
+        return $this->mentionedMessages;
+    }
+
+    public function addMentionedMessage(Message $mentionedMessage): self
+    {
+        if (!$this->mentionedMessages->contains($mentionedMessage)) {
+            $this->mentionedMessages[] = $mentionedMessage;
+            $mentionedMessage->addMentiotest($this);
+        }
+
+        return $this;
+    }
+
+    public function removeMentionedMessage(Message $mentionedMessage): self
+    {
+        if ($this->mentionedMessages->removeElement($mentionedMessage)) {
+            $mentionedMessage->removeMentiotest($this);
+        }
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|Retweets[]
+     */
+    public function getRetweets(): Collection
+    {
+        return $this->retweets;
+    }
+
+    public function addRetweet(Retweets $retweet): self
+    {
+        if (!$this->retweets->contains($retweet)) {
+            $this->retweets[] = $retweet;
+            $retweet->addRetweeter($this);
+        }
+
+        return $this;
+    }
+
+    public function removeRetweet(Retweets $retweet): self
+    {
+        if ($this->retweets->removeElement($retweet)) {
+            $retweet->removeRetweeter($this);
+        }
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|PrivateDiscussion[]
+     */
+    public function getPrivateDiscussions(): Collection
+    {
+        return $this->privateDiscussions;
+    }
+
+    public function addPrivateDiscussion(PrivateDiscussion $privateDiscussion): self
+    {
+        if (!$this->privateDiscussions->contains($privateDiscussion)) {
+            $this->privateDiscussions[] = $privateDiscussion;
+            $privateDiscussion->addParticipant($this);
+        }
+
+        return $this;
+    }
+
+    public function removePrivateDiscussion(PrivateDiscussion $privateDiscussion): self
+    {
+        if ($this->privateDiscussions->removeElement($privateDiscussion)) {
+            $privateDiscussion->removeParticipant($this);
+        }
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|PrivateMessage[]
+     */
+    public function getPrivateMessages(): Collection
+    {
+        return $this->privateMessages;
+    }
+
+    public function addPrivateMessage(PrivateMessage $privateMessage): self
+    {
+        if (!$this->privateMessages->contains($privateMessage)) {
+            $this->privateMessages[] = $privateMessage;
+            $privateMessage->setSender($this);
+        }
+
+        return $this;
+    }
+
+    public function removePrivateMessage(PrivateMessage $privateMessage): self
+    {
+        if ($this->privateMessages->removeElement($privateMessage)) {
+            // set the owning side to null (unless already changed)
+            if ($privateMessage->getSender() === $this) {
+                $privateMessage->setSender(null);
+            }
+        }
+
+        return $this;
+    }
 }

+ 50 - 0
src/Repository/PrivateDiscussionRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository;
+
+use App\Entity\PrivateDiscussion;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method PrivateDiscussion|null find($id, $lockMode = null, $lockVersion = null)
+ * @method PrivateDiscussion|null findOneBy(array $criteria, array $orderBy = null)
+ * @method PrivateDiscussion[]    findAll()
+ * @method PrivateDiscussion[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class PrivateDiscussionRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, PrivateDiscussion::class);
+    }
+
+    // /**
+    //  * @return PrivateDiscussion[] Returns an array of PrivateDiscussion objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('p')
+            ->andWhere('p.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('p.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?PrivateDiscussion
+    {
+        return $this->createQueryBuilder('p')
+            ->andWhere('p.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/PrivateMessageRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository;
+
+use App\Entity\PrivateMessage;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method PrivateMessage|null find($id, $lockMode = null, $lockVersion = null)
+ * @method PrivateMessage|null findOneBy(array $criteria, array $orderBy = null)
+ * @method PrivateMessage[]    findAll()
+ * @method PrivateMessage[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class PrivateMessageRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, PrivateMessage::class);
+    }
+
+    // /**
+    //  * @return PrivateMessage[] Returns an array of PrivateMessage objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('p')
+            ->andWhere('p.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('p.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?PrivateMessage
+    {
+        return $this->createQueryBuilder('p')
+            ->andWhere('p.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/RetweetsRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository;
+
+use App\Entity\Retweets;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method Retweets|null find($id, $lockMode = null, $lockVersion = null)
+ * @method Retweets|null findOneBy(array $criteria, array $orderBy = null)
+ * @method Retweets[]    findAll()
+ * @method Retweets[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class RetweetsRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, Retweets::class);
+    }
+
+    // /**
+    //  * @return Retweets[] Returns an array of Retweets objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('r')
+            ->andWhere('r.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('r.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?Retweets
+    {
+        return $this->createQueryBuilder('r')
+            ->andWhere('r.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 18 - 0
templates/private_discussion/index.html.twig

@@ -0,0 +1,18 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Hello PrivateDiscussionController!{% endblock %}
+
+{% block body %}
+    <ul>
+    {% for msg in messages %}
+        <li>
+            <div>{{ msg.sender.getUsername() }}</div>
+            <div>{{ msg.text }}</div>
+        </li>
+    {% endfor %}
+    </ul>
+    {{ form_start(form) }}
+    {{ form_errors(form) }}
+    {{ form_widget(form) }} <input type="submit">
+    {{ form_end(form) }}
+{% endblock %}

+ 21 - 0
templates/private_discussions/index.html.twig

@@ -0,0 +1,21 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Hello PrivateDiscussionsController!{% endblock %}
+
+{% block body %}
+    {{ form_start(form) }}
+    {{ form_errors(form) }}
+    {{ form_widget(form) }} <input type="submit">
+    {{ form_end(form) }}
+    <ul>
+    {% for pd in private_discussions %}
+        {% for key, value in pd %}
+            <li>
+                <div>
+                <a href={{ path('private_discussion', {'id': key }) }}>Discussion privée avec </a><a href={{ path('profile', {'username': value }) }}>@{{ value }}</a>
+                </div>
+            </li>
+        {% endfor %}
+    {% endfor %}
+    </ul>
+{% endblock %}