Refactoring

This commit is contained in:
Jannis Portmann 2021-06-06 11:20:51 +02:00
parent 8c120bd872
commit d550d01464

View file

@ -14,20 +14,14 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email; use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
class TradeController extends AbstractController class TradeController extends AbstractController
{ {
#[Route('/trade/{id}', name: 'trade')] #[Route('/trade/{id}', name: 'trade')]
public function sendEmail(MailerInterface $mailer, Offering $offer, OfferingRepository $offeringRepository, WishRepository $wishRepository, RouterInterface $router): Response public function sendEmail(MailerInterface $mailer, Offering $offer, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response
{ {
$user = $this->getUser(); $user = $this->getUser();
$this->router = $router;
$mail_url = $this->router->generate('user_public', [
'id' => $offer->getByUser()->getId(),
], UrlGeneratorInterface::ABSOLUTE_URL);
if($user != $offer->getByUser()) if($user != $offer->getByUser())
{ {
@ -40,8 +34,7 @@ class TradeController extends AbstractController
->htmlTemplate('user/trade/offer_email.html.twig') ->htmlTemplate('user/trade/offer_email.html.twig')
->context([ ->context([
'user' => $user, 'user' => $user,
'id' => $offer->getByUser()->getId(), 'id' => $user->getId(),
'userOffersLink' => $mail_url,
]) ])
; ;
try try