<?php
declare(strict_types=1);
namespace Wbfk\ShopwareFixes\CoreFixes\Content\Mail\Service;
use League\Flysystem\FilesystemInterface;
use Shopware\Core\Content\Mail\Service\MailAttachmentsBuilder;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Transport\TransportInterface;
class MailerTransportFactory extends Transport
{
public function __construct(
private readonly \Shopware\Core\Content\Mail\Service\MailerTransportFactory $inner,
private readonly iterable $factories,
private readonly SystemConfigService $configService,
private readonly MailAttachmentsBuilder $attachmentsBuilder,
private readonly FilesystemInterface $filesystem,
private readonly EntityRepositoryInterface $documentRepository
) {
parent::__construct($factories);
}
public function fromString(string $dsn): TransportInterface
{
if (trim($this->configService->getString('core.mailerSettings.emailAgent')) === '') {
return new MailerTransportDecorator(
parent::fromString($dsn),
$this->attachmentsBuilder,
$this->filesystem,
$this->documentRepository
);
}
return new MailerTransportDecorator(
$this->inner->create(),
$this->attachmentsBuilder,
$this->filesystem,
$this->documentRepository
);
}
}