Review main Abandoned

90127[WIP][FEATURE] Introduce FluidEmail factory

Garvin Hicking CR 0 V -1 Expert +1016 −177 updated 02/04/26, 20:25

Commit message

Getting there; generally old and new API seem to work.

Old:
```
    $email = new TYPO3\CMS\Core\Mail\FluidEmail();
    $email->setTemplate('MyTemplate')
      ->assign('data', $data)
      ->to('recipient@example.com')
      ->subject('Hello');
```

New:
```
    class someActionController {
        public function __construct(
            private TYPO3\CMS\Core\Mail\FluidEmailTemplateRendererFactoryInterface $emailRendererFactory,
            private TYPO3\CMS\Core\Mail\FluidEmailFactory $emailFactory,
            private TYPO3\CMS\Core\Mail\MailerInterface $mailer,
        ) {}

        public function sendEmailAction(array $data): void
        {
            $renderer = $this->emailRendererFactory->create();
            $renderer->setTemplate('MyTemplate')
                ->assign('data', $data);

            $email = $this->emailFactory->createFromRenderer($renderer)
                ->to('recipient@example.com')
                ->subject('Hello');
            $mailer->send($email);
        }
    }
```

TODO:

* Fix flawed format change rendering
* Using our own interface to type Symfony "Email" is annoying.
  Maybe use 'FluidEmailMessage' as the real type hint instead of a
  'FluidEmailInterface'. However that locks us into Symfony Mail, too.
* Implement the reason I want this: An easy way to
  have the factory create a FluidEmail instance with proper
  CLI attached to it. Stub method
  `FluidMailFactory->createFromRendererWithFrontendContext`.

That CLI method should take a string (site identifier) or int
(page uid) and utilize the SiteFinder for something like:

```
 $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId(1);
 // (or by site identifier)
 $host = ($site->getBase()->getPort())
         ? $site->getBase()->getHost() . ':' . $site->getBase()->getPort()
         : $site->getBase()->getHost();
 $normalizedParams = new NormalizedParams([
     'HTTP_HOST' => $host,
     'HTTPS' => $site->getBase()->getScheme() === 'https' ? 'on' : 'off',
   ],
   $GLOBALS['TYPO3_CONF_VARS']['SYS'],
   '',
   ''
 );
 $request = (new ServerRequest())
     ->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE)
     ->withAttribute('normalizedParams', $normalizedParams)
     ->withAttribute('site', $site);
 // Now put the $request and the lime in the coconut and mail it all up
```

Review

  • Code review CR 0
  • Verified V -1
    • core-ci -1 CI

Issues 3

Files 27

Show 7 more files

Review log 56

  1. Garvin Hicking uploaded patch set 1 07/23/25, 11:59

  2. core-ci voted on patch set 1 V -1 07/23/25, 12:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82164

  3. Garvin Hicking marked it work in progress 09/10/25, 13:27

  4. Simon Schaufelberger commented on patch set 1 02/04/26, 16:51

    I guess this can be abandoned in favor of https://review.typo3.org/c/Packages/TYPO3.CMS/+/92483. What do you think?
  5. Garvin Hicking commented on patch set 1 02/04/26, 20:25

    Reply Unresolved

    Yes.
  6. Garvin Hicking abandoned the change 02/04/26, 20:25