oliverkroener/ok-typo3-helper

A TYPO3 extension with helper traits and utilities.

Maintainers

Package info

github.com/oliverkroener/ok_typo3_helper

Homepage

Type:typo3-cms-extension

pkg:composer/oliverkroener/ok-typo3-helper

Transparency log

Statistics

Installs: 17 906

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

3.1.2 2026-07-16 04:29 UTC

README

TYPO3 12 TYPO3 13 TYPO3 14 PHP 8.1+ License: GPL v2+ Version

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 Symfony SentMessage into a Microsoft Graph Message object ready for the Graph sendMail endpoint. It maps From/To/Cc/Bcc/Reply-To recipients, HTML and plain-text bodies, and file attachments. This is the conversion layer used by ok_exchange365_mailer.
    • Inline images (cid:) support — attachments marked Content-Disposition: inline are flagged as inline and their original MIME Content-ID is carried onto the Graph FileAttachment. 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 via getContentId(), which already returns the value without the surrounding <> so it matches the cid: reference in the body verbatim.
  • Site root resolver (SiteRootService) — a singleton service that returns the site root page UID for any given page UID, resolving SiteNotFoundException to null.
  • Reflection accessor trait (ReflectionPropertiesTrait) — adds dynamic getXxx() / setXxx() access to any class's properties (including protected/private) via __call() and reflection.

Requirements

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.