Developer
Architecture
Ai3 Summary follows the Ai3 Suite capability pattern provided by wegewerk/ai3_core :
- A Capability class registers the feature under a unique key.
- An Endpoint class implements the ZAK-AI API call.
- A FormEngine element renders the backend widget.
- A backend AJAX controller handles the generation request.
PHP API
ArticlesummaryCapability
- class ArticlesummaryCapability
-
- Fully qualified name
-
\Wegewerk\
Ai3Summary\ Domain\ Capabilities\ Articlesummary Capability
Extends
Wegewerk\Ai3Core\Domain\Capabilities\Capability. Registered viaConfiguration/Services.yamlwith the following wiring:$key:articlesummary$title:Article Summary$endpoint:ZakAiSummary- Tagged as
ai3.capability
ZakAiSummary
- class ZakAiSummary
-
- Fully qualified name
-
\Wegewerk\
Ai3Summary\ Api\ Zak Ai Summary
Implements
Wegewerk\Ai3Core\Api\ZakAiEndpointInterface. WrapsZakAiClientto call the ZAK-AIbulletpointsREST endpoint.- generate ( $imagePath, $description, $language)
-
Sends page content to the ZAK-AI API and returns the generated bullet-point summary string.
- param string $imagePath
-
Unused; reserved for future use.
- param string $description
-
The page content text to summarise.
- param string $language
-
The target language for the summary.
- returntype
-
string
ArticlesummaryController
- class ArticlesummaryController
-
- Fully qualified name
-
\Wegewerk\
Ai3Summary\ Controller\ Ajax\ Articlesummary Controller
Backend AJAX controller (
#[AsController]), extendsWegewerk\Ai3Core\Controller\Ajax\AbstractAjaxController.- getArticlesummary ( ServerRequestInterface $request)
-
Handles the AJAX generation request.
- Reads
page_idandlanguagefrom the POST body. - Fetches all page content via
PagesRepository::getPageContent(). - Calls
ArticlesummaryCapabilityendpoint to generate the summary. - Returns a JSON response with
summary,source, andtype: 'summary'on success, or an error JSON on failure.
- returntype
-
ResponseInterface
- Reads
FormEngine integration
The custom FormEngine node ai3SummaryElement is registered in
ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1759225980] = [
'nodeName' => 'ai3SummaryElement',
'priority' => 40,
'class' => \Wegewerk\Ai3Summary\FormEngine\Ai3SummaryElement::class,
];
The element is added to the tt_content TCA via
Configuration/TCA/Overrides/tt_content_summary.php as a column of
type user with renderType: ai3SummaryElement.
- class Ai3SummaryElement
-
- Fully qualified name
-
\Wegewerk\
Ai3Summary\ Form Engine\ Ai3Summary Element
Extends
TYPO3\CMS\Backend\Form\Element\AbstractFormElement. Renders a<div data-ai3="ai3-summary-container">withdata-page-idanddata-record-uidattributes. The Lit-HTMLSummaryAppmounts into the inner<div data-ai3="ai3-summary-app">.
AJAX route
The backend AJAX route is registered in
Configuration/Backend/AjaxRoutes.php:
| Route name | Path | Handler |
|---|---|---|
ai3_articlesummary | /ai3/articlesummary | ArticlesummaryController::getArticlesummary |
Request (POST, JSON body):
{
"page_id": 42,
"language": "en"
}
Response (success):
{
"summary": "• Point one\n• Point two",
"source": "articlesummary",
"type": "summary"
}
JavaScript modules
JavaScript modules are registered via Configuration/JavaScriptModules.php
under the @wegewerk/Ai3Summary/ import map prefix.
- ``@wegewerk/Ai3Summary/ai3api`` --
Ai3Apiclass withgetArticlesummary(pageId, language)that POSTs to the AJAX route via TYPO3'sAjaxRequest. - ``@wegewerk/Ai3Summary/summary`` -- Lit-HTML
SummaryAppthat renders the backend widget, handles the button click, callsAi3Api, and writes the result into thebodytextfield (CKEditor 5 and CKEditor 4 fallback supported).
Event listener
- class AfterFormEnginePageInitializedEventListener
-
- Fully qualified name
-
\Wegewerk\
Ai3Summary\ Event Listener\ After Form Engine Page Initialized Event Listener
Listens to
AfterFormEnginePageInitializedEvent(#[AsEventListener]). Adds the extension'slocallang.xlfas an inline language label file to thePageRenderer, making all translation keys available to JavaScript.