<?php
namespace App\Utils\OrderCreator\Event\Handler;
use App\Utils\MailerUtils;
use App\Utils\OrderCreator\Event\OrderPlacingFinished;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: OrderPlacingFinished::class)]
final class ManaulVerificationNotifyHandler
{
public function __construct(private readonly MailerUtils $mailerUtils)
{}
public function __invoke(OrderPlacingFinished $event): void
{
$orderContext = $event->getOrderCreationContext();
$order = $orderContext->getOrder();
$portalSettings = $orderContext->getResolvedPortalSettings();
$manualVerificationEnabled = $orderContext->isManualVerificationNotify() ?? false;
if ($manualVerificationEnabled) {
$this->mailerUtils->sendManualVerificationNotify($order, $portalSettings->getTitle());
}
}
}