2024-08-16 23:23:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Notifier;
|
|
|
|
|
|
|
|
|
|
use App\Entity\Connector;
|
|
|
|
|
use App\Entity\Domain;
|
|
|
|
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
|
|
|
|
use Symfony\Component\Mime\Address;
|
|
|
|
|
use Symfony\Component\Mime\Email;
|
|
|
|
|
use Symfony\Component\Notifier\Message\ChatMessage;
|
|
|
|
|
use Symfony\Component\Notifier\Message\EmailMessage;
|
2024-08-27 21:44:42 +02:00
|
|
|
use Symfony\Component\Notifier\Message\PushMessage;
|
2024-08-16 23:23:51 +02:00
|
|
|
use Symfony\Component\Notifier\Notification\Notification;
|
|
|
|
|
use Symfony\Component\Notifier\Recipient\EmailRecipientInterface;
|
|
|
|
|
use Symfony\Component\Notifier\Recipient\RecipientInterface;
|
|
|
|
|
|
2024-08-28 17:35:32 +02:00
|
|
|
class DomainOrderNotification extends DomainWatchdogNotification
|
2024-08-16 23:23:51 +02:00
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly Address $sender,
|
|
|
|
|
private readonly Domain $domain,
|
2024-11-01 00:46:25 +01:00
|
|
|
private readonly Connector $connector,
|
2024-08-16 23:23:51 +02:00
|
|
|
) {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function asChatMessage(?RecipientInterface $recipient = null, ?string $transport = null): ?ChatMessage
|
|
|
|
|
{
|
2024-08-17 00:36:00 +02:00
|
|
|
$ldhName = $this->domain->getLdhName();
|
|
|
|
|
$this
|
|
|
|
|
->subject("Success: Domain Ordered $ldhName!")
|
|
|
|
|
->content("Domain name $ldhName has just been purchased. The API provider did not return an error.")
|
|
|
|
|
->importance(Notification::IMPORTANCE_HIGH);
|
2024-08-16 23:23:51 +02:00
|
|
|
|
|
|
|
|
return ChatMessage::fromNotification($this);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 21:44:42 +02:00
|
|
|
public function asPushMessage(?RecipientInterface $recipient = null, ?string $transport = null): ?PushMessage
|
|
|
|
|
{
|
|
|
|
|
$ldhName = $this->domain->getLdhName();
|
|
|
|
|
$this
|
|
|
|
|
->subject("Success: Domain Ordered $ldhName!")
|
|
|
|
|
->content("Domain name $ldhName has just been purchased. The API provider did not return an error.")
|
|
|
|
|
->importance(Notification::IMPORTANCE_HIGH);
|
|
|
|
|
|
|
|
|
|
return PushMessage::fromNotification($this);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-30 12:54:42 +02:00
|
|
|
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
2024-08-16 23:23:51 +02:00
|
|
|
{
|
2025-01-02 18:08:51 +01:00
|
|
|
$ldhName = $this->domain->getLdhName();
|
|
|
|
|
|
2024-08-16 23:23:51 +02:00
|
|
|
return new EmailMessage((new TemplatedEmail())
|
|
|
|
|
->from($this->sender)
|
|
|
|
|
->to($recipient->getEmail())
|
|
|
|
|
->priority(Email::PRIORITY_HIGHEST)
|
2025-01-02 18:08:51 +01:00
|
|
|
->subject("Domain name $ldhName has just been purchased")
|
2024-08-16 23:23:51 +02:00
|
|
|
->htmlTemplate('emails/success/domain_ordered.html.twig')
|
|
|
|
|
->locale('en')
|
|
|
|
|
->context([
|
|
|
|
|
'domain' => $this->domain,
|
|
|
|
|
'provider' => $this->connector->getProvider()->value,
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
}
|