2026-02-23 12:58:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Service\Mail;
|
|
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
use MintyPHP\Repository\Mail\MailLogRepositoryInterface;
|
2026-03-06 00:44:52 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingsSmtpGateway;
|
2026-02-23 12:58:19 +01:00
|
|
|
|
|
|
|
|
class MailServicesFactory
|
|
|
|
|
{
|
|
|
|
|
private ?MailService $mailService = null;
|
|
|
|
|
private ?MailLogService $mailLogService = null;
|
|
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
public function __construct(
|
|
|
|
|
private readonly MailRepositoryFactory $mailRepositoryFactory,
|
2026-03-06 00:44:52 +01:00
|
|
|
private readonly SettingsSmtpGateway $settingsSmtpGateway
|
2026-03-05 11:17:42 +01:00
|
|
|
) {
|
|
|
|
|
}
|
2026-03-04 15:56:58 +01:00
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
public function createMailLogRepository(): MailLogRepositoryInterface
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-04 15:56:58 +01:00
|
|
|
return $this->mailRepositoryFactory->createMailLogRepository();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createMailService(): MailService
|
|
|
|
|
{
|
|
|
|
|
return $this->mailService ??= new MailService(
|
|
|
|
|
$this->createMailLogRepository(),
|
2026-03-06 00:44:52 +01:00
|
|
|
$this->createSettingsSmtpGateway()
|
2026-02-23 12:58:19 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createMailLogService(): MailLogService
|
|
|
|
|
{
|
|
|
|
|
return $this->mailLogService ??= new MailLogService($this->createMailLogRepository());
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 00:44:52 +01:00
|
|
|
private function createSettingsSmtpGateway(): SettingsSmtpGateway
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-06 00:44:52 +01:00
|
|
|
return $this->settingsSmtpGateway;
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
}
|