|
|
@@ -6,6 +6,7 @@ use App\Entity\Hashtag;
|
|
|
use App\Entity\Message;
|
|
|
use App\Entity\Retweets;
|
|
|
use App\Entity\User;
|
|
|
+use App\Form\MessageType;
|
|
|
use Doctrine\DBAL\Types\TextType;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
@@ -33,10 +34,8 @@ class HomeController extends AbstractController
|
|
|
return $this->redirectToRoute('home');
|
|
|
}
|
|
|
|
|
|
- $formBuilder = $this->createFormBuilder();
|
|
|
- $formBuilder->add('text', \Symfony\Component\Form\Extension\Core\Type\TextType::class,['label' => 'Envoyer un message'])
|
|
|
- ->setAction($this->generateUrl('home'));
|
|
|
- $form = $formBuilder->getForm();
|
|
|
+ $options = array("action" => $this->generateUrl('home'));
|
|
|
+ $form = $this->createForm(MessageType::class, null, $options);
|
|
|
|
|
|
if ($request->getMethod() == 'POST') {
|
|
|
$form->handleRequest($request);
|
|
|
@@ -51,7 +50,7 @@ class HomeController extends AbstractController
|
|
|
$hashtags = array();
|
|
|
preg_match_all("~@([a-zA-Z0-9_]*)~", $text, $mentions);
|
|
|
preg_match_all("~#([a-zA-Z0-9_]*)~", $text, $hashtags);
|
|
|
- for($i=0; $i < sizeof($mentions[0]); $i++) {
|
|
|
+ for ($i = 0; $i < sizeof($mentions[0]); $i++) {
|
|
|
$user = $repository_profile->findOneBy(array('username' => $mentions[1][$i]));
|
|
|
if ($user) {
|
|
|
$message->addMention($user);
|
|
|
@@ -63,7 +62,7 @@ class HomeController extends AbstractController
|
|
|
}
|
|
|
}
|
|
|
$repository_hashtag = $em->getRepository(Hashtag::class);
|
|
|
- for($i=0; $i < sizeof($hashtags[0]); $i++) {
|
|
|
+ for ($i = 0; $i < sizeof($hashtags[0]); $i++) {
|
|
|
$hashtag = $repository_hashtag->findOneBy(array('name' => $hashtags[1][$i]));
|
|
|
if (!$hashtag) {
|
|
|
$hashtag = new Hashtag();
|
|
|
@@ -125,7 +124,8 @@ class HomeController extends AbstractController
|
|
|
}
|
|
|
|
|
|
#[Route('/rt/{msgId}', name: 'rt_message')]
|
|
|
- public function retweet($msgId) {
|
|
|
+ public function retweet($msgId)
|
|
|
+ {
|
|
|
$session = $this->get('session');
|
|
|
|
|
|
if (null === $session->get('user')) {
|