start working on trade email sending
This commit is contained in:
parent
222d35e1b4
commit
bed4012971
2 changed files with 44 additions and 0 deletions
39
src/Controller/TradeController.php
Normal file
39
src/Controller/TradeController.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Repository\OfferingRepository;
|
||||
use App\Repository\WishRepository;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class TradeController extends AbstractController
|
||||
{
|
||||
#[Route('/trade/{id}', name: 'trade')]
|
||||
public function sendEmail(MailerInterface $mailer, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$offer = $offeringRepository->();
|
||||
|
||||
if(/* user not the logged in user */)
|
||||
$email = (new Email())
|
||||
->from('no-reply@pfleanz.li')
|
||||
->to(/* user of offer */)
|
||||
->replyTo(/* logged in user */)
|
||||
->subject('Time for Symfony Mailer!')
|
||||
->text('Sending emails is fun again!')
|
||||
->htmlTemplate('user/trade/offer_email.html.twig');
|
||||
try
|
||||
{
|
||||
$mailer->send($email);
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
// TODO:
|
||||
// print error
|
||||
}
|
||||
return $this->redirectToRoute('/offer', {'id': $id});
|
||||
}
|
||||
}
|
5
templates/offer/trade/trade_email.html.twig
Normal file
5
templates/offer/trade/trade_email.html.twig
Normal file
|
@ -0,0 +1,5 @@
|
|||
<h1>{{ user.username}} wants to trade!</h1>
|
||||
|
||||
<p>You can checkout their offer and reply to this email if you want to trade.</p>
|
||||
|
||||
<a href={{ path('user_public', id: { 'id': offer.byuser.id }) }}</a>
|
Reference in a new issue