This repository has been archived by the owner on Dec 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
<?php | ||
namespace App\MessageHandler; | ||
|
||
use App\Entity\Comment; | ||
use App\Entity\User; | ||
use App\Message\SendComment; | ||
use App\Repository\CommentRepository; | ||
use App\Service\SendDossierCommentsService; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface; | ||
use Symfony\Component\Messenger\Attribute\AsMessageHandler; | ||
|
||
#[AsMessageHandler] | ||
class SendCommentHandler | ||
{ | ||
public function __construct(private EntityManagerInterface $em, private SendDossierCommentsService $service) | ||
public function __construct(private CommentRepository $commentRepository, private SendDossierCommentsService $service) | ||
{ | ||
} | ||
|
||
/** | ||
* @throws TransportExceptionInterface | ||
*/ | ||
public function __invoke(SendComment $message): void | ||
{ | ||
// do something with your message | ||
$user = $this->em->find(User::class, $message->getUserId()); | ||
$comment = $this->em->find(Comment::class, $message->getCommentId()); | ||
$comment = $this->commentRepository->find($message->getCommentId()); | ||
|
||
// On vérifie qu'on a toutes les informations nécessaires | ||
if($newsletter !== null && $user !== null){ | ||
if (!empty($comment) && empty($comment->getSent())) { | ||
$this->service->send($comment); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<h1>{{ dossier.title }}</h1> | ||
<h3>New comments in dossier: <a href="{{ absolute_url(path('dossierItem', {'id': comment.dossier.id})) }}">{{ comment.dossier.title }}</a></h3> | ||
<p>On {{ comment.createdDate|date('d/m/Y') }}, by {{ comment.author.username|capitalize }}.</p> | ||
|
||
<div> | ||
{{newsletter.content|raw}} | ||
</div> | ||
{{comment.content|nl2br}} | ||
</div> |