oliverkroener / ok-typo3-helper
A TYPO3 extension with helper traits and utilities.
Package info
github.com/oliverkroener/ok_typo3_helper
Type:typo3-cms-extension
pkg:composer/oliverkroener/ok-typo3-helper
Requires
- microsoft/microsoft-graph: ^2
- typo3/cms-core: ^12 || ^13 || ^14
- zbateson/mail-mime-parser: ^3
README
Reusable helper traits, services, and a Microsoft Graph mail converter that other Oliver Kröner TYPO3 extensions build on.
Features
- Microsoft Graph mail converter (
MSGraphMailApiService) — converts a SymfonySentMessageinto a Microsoft GraphMessageobject ready for the GraphsendMailendpoint. It maps From/To/Cc/Bcc/Reply-To recipients, HTML and plain-text bodies, and file attachments. This is the conversion layer used byok_exchange365_mailer.- Inline images (
cid:) support — attachments markedContent-Disposition: inlineare flagged as inline and their original MIMEContent-IDis carried onto the GraphFileAttachment. Without this, Graph cannot bind an<img src="cid:…">in the HTML body to its attachment and the image renders broken. The Content-ID is read viagetContentId(), which already returns the value without the surrounding<>so it matches thecid:reference in the body verbatim.
- Inline images (
- Site root resolver (
SiteRootService) — a singleton service that returns the site root page UID for any given page UID, resolvingSiteNotFoundExceptiontonull. - Reflection accessor trait (
ReflectionPropertiesTrait) — adds dynamicgetXxx()/setXxx()access to any class's properties (including protected/private) via__call()and reflection.
Requirements
- TYPO3 12.4 LTS, 13.4 LTS, or 14 LTS
- PHP 8.1 or newer
microsoft/microsoft-graph^2(pulled in automatically)zbateson/mail-mime-parser^3(pulled in automatically)
Installation
Install via Composer:
composer require oliverkroener/ok-typo3-helper
As a local path-repository extension (as used in this project), add the package under packages/ and require it as a dev version:
composer require oliverkroener/ok-typo3-helper:@dev
Then set it up:
vendor/bin/typo3 extension:setup vendor/bin/typo3 cache:flush
Usage
Converting a message for Microsoft Graph
MSGraphMailApiService::convertToGraphMessage() is static and takes a Symfony SentMessage, returning an array with the built Graph message and the resolved from address:
use OliverKroener\Helpers\MSGraphApi\MSGraphMailApiService; $result = MSGraphMailApiService::convertToGraphMessage($sentMessage); $graphMessage = $result['message']; // Microsoft\Graph\Generated\Models\Message $fromAddress = $result['from']; // string|null
Inline images work automatically: build the mail with Symfony's ->embed() (or a TYPO3 Fluid mail template with an inline image), and the resulting cid: reference in the HTML body is preserved end-to-end into the Graph attachment's contentId.
Resolving the site root
use OliverKroener\Helpers\Service\SiteRootService; // Injected via DI (registered public in Configuration/Services.yaml) $rootPageId = $siteRootService->findNextSiteRoot($currentPageId); // int|null
Dynamic property accessors
use OliverKroener\Helpers\Traits\ReflectionPropertiesTrait; class MyModel { use ReflectionPropertiesTrait; private string $title = ''; } $model = new MyModel(); $model->setTitle('Hello'); // routed through __call → reflection echo $model->getTitle(); // "Hello"
Architecture
| Component | Class | Role |
|---|---|---|
| Graph mail converter | OliverKroener\Helpers\MSGraphApi\MSGraphMailApiService |
Parses a MIME SentMessage and rebuilds it as a Graph Message |
| Site root resolver | OliverKroener\Helpers\Service\SiteRootService |
Maps a page UID to its site root page UID (singleton, DI-registered) |
| Reflection trait | OliverKroener\Helpers\Traits\ReflectionPropertiesTrait |
Dynamic getters/setters via __call() + reflection |
ok_typo3_helper/
├── Classes/
│ ├── MSGraphApi/
│ │ └── MSGraphMailApiService.php
│ ├── Service/
│ │ └── SiteRootService.php
│ └── Traits/
│ └── ReflectionPropertiesTrait.php
├── Configuration/
│ └── Services.yaml
├── Resources/
│ └── Public/Icons/Extension.png
├── ext_emconf.php
├── ext_localconf.php
└── composer.json
License
This extension is licensed under the GPL-2.0-or-later. See the LICENSE file for the full text.
Author — Oliver Kroener
Automated. Scaled. Done.
Web3 · Cloud · Automation
Technology is only valuable when it solves a real problem. For over 30 years I've been translating between business and tech — so your investment in digitalisation doesn't stall at proof-of-concept but delivers measurable results.
- Website: oliver-kroener.de
- Web3: web3.oliver-kroener.de
- Email: ok@oliver-kroener.de
- Web3 Email: oliverkroener@ethermail.io