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\. Registered viaAi3Core\ Domain\ Capabilities\ Capability Configuration/with the following wiring:Services. yaml $key:articlesummary$title:Article Summary$endpoint:ZakAi Summary - Tagged as
ai3.capability
ZakAiSummary
-
class
ZakAiSummary -
- Fully qualified name
-
\Wegewerk\Ai3Summary\ Api\ Zak Ai Summary
Extends
Wegewerk\(implementingAi3Core\ Api\ Abstract Zak Ai Endpoint Zak). WrapsAi Endpoint Interface Zakto call the ZAK-AIAi Client bulletpointsREST endpoint.generate(array $options = [])-
Sends page content to the ZAK-AI API and returns the generated bullet-point summary string.
- param array $options
-
Associative array of options: ``text`` (string, required): The page content text to summarise.
language(string, optional): The target language for the summary (default: 'de'). - returntype
-
string
ArticlesummaryController
-
class
ArticlesummaryController -
- Fully qualified name
-
\Wegewerk\Ai3Summary\ Controller\ Ajax\ Articlesummary Controller
Backend AJAX controller (
#), extends[As Controller] Wegewerk\.Ai3Core\ Controller\ Ajax\ Abstract Ajax Controller getArticlesummary(ServerRequestInterface $request)-
Handles the AJAX generation request.
- Reads
page_andid languagefrom the POST body. - Fetches all page content via
Pages.Repository:: get Page Content () - Calls
Articlesummaryendpoint to generate the summary.Capability - 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 ai3Summary is registered in
ext_:
$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_ TCA via
Configuration/ as a column of
type user with render.
-
class
Ai3SummaryElement -
- Fully qualified name
-
\Wegewerk\Ai3Summary\ Form Engine\ Ai3Summary Element
Extends
TYPO3\. Renders aCMS\ Backend\ Form\ Element\ Abstract Form Element <div data-withai3="ai3- summary- container"> data-andpage- id data-attributes. The Lit-HTMLrecord- uid Summarymounts into the innerApp <div data-.ai3="ai3- summary- app">
AJAX route
The backend AJAX route is registered in
Configuration/:
| Route name | Path | Handler |
|---|---|---|
ai3_ | /ai3/ | Articlesummary |
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/
under the @wegewerk/ import map prefix.
- ``@wegewerk/Ai3Summary/ai3api`` --
Ai3Apiclass withgetthat POSTs to the AJAX route via TYPO3'sArticlesummary (page Id, language) Ajax.Request - ``@wegewerk/Ai3Summary/summary`` -- Lit-HTML
Summarythat renders the backend widget, handles the button click, callsApp Ai3Api, 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
After(Form Engine Page Initialized Event #). Adds the extension's[As Event Listener] locallang.as an inline language label file to thexlf Page, making all translation keys available to JavaScript.Renderer