custom/plugins/WbfkShopwareFixes/src/CoreFixes/Content/Mail/Service/MailerTransportFactory.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Wbfk\ShopwareFixes\CoreFixes\Content\Mail\Service;
  4. use League\Flysystem\FilesystemInterface;
  5. use Shopware\Core\Content\Mail\Service\MailAttachmentsBuilder;
  6. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  7. use Shopware\Core\System\SystemConfig\SystemConfigService;
  8. use Symfony\Component\Mailer\Transport;
  9. use Symfony\Component\Mailer\Transport\TransportInterface;
  10. class MailerTransportFactory extends Transport
  11. {
  12.     public function __construct(
  13.         private readonly \Shopware\Core\Content\Mail\Service\MailerTransportFactory $inner,
  14.         private readonly iterable $factories,
  15.         private readonly SystemConfigService $configService,
  16.         private readonly MailAttachmentsBuilder $attachmentsBuilder,
  17.         private readonly FilesystemInterface $filesystem,
  18.         private readonly EntityRepositoryInterface $documentRepository
  19.     ) {
  20.         parent::__construct($factories);
  21.     }
  22.     public function fromString(string $dsn): TransportInterface
  23.     {
  24.         if (trim($this->configService->getString('core.mailerSettings.emailAgent')) === '') {
  25.             return new MailerTransportDecorator(
  26.                 parent::fromString($dsn),
  27.                 $this->attachmentsBuilder,
  28.                 $this->filesystem,
  29.                 $this->documentRepository
  30.             );
  31.         }
  32.         return new MailerTransportDecorator(
  33.             $this->inner->create(),
  34.             $this->attachmentsBuilder,
  35.             $this->filesystem,
  36.             $this->documentRepository
  37.         );
  38.     }
  39. }