.. include:: /Includes.rst.txt .. _developer: ========= Developer ========= .. _developer-architecture: Architecture ============ Ai3 FAQ follows the *Ai3 Suite* capability pattern provided by :composer:`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. * **Bootstrap Package integration** provides accordion functionality. .. _developer-php-api: PHP API ======= .. _developer-articlefaq-capability: ArticlefaqCapability -------------------- .. php:class:: Wegewerk\Ai3Faq\Domain\Capabilities\ArticlefaqCapability Extends ``Wegewerk\Ai3Core\Domain\Capabilities\Capability``. Registered via ``Configuration/Services.yaml`` with the following wiring: * ``$key``: ``articlefaq`` * ``$title``: ``Article FAQ`` * ``$endpoint``: ``ZakAiFaq`` * Tagged as ``ai3.capability`` .. _developer-zakai-faq: ZakAiFaq -------- .. php:class:: Wegewerk\Ai3Faq\Api\ZakAiFaq Implements ``Wegewerk\Ai3Core\Api\ZakAiEndpointInterface``. Wraps ``ZakAiClient`` to call the ZAK-AI ``faq`` REST endpoint. .. php:method:: generate($imagePath, $description, $language) Sends page content to the ZAK-AI API and returns the generated FAQ data as a JSON string containing question-answer pairs. :param string $imagePath: Unused; reserved for future use. :param string $description: The page content text to analyze for FAQ generation. :param string $language: The target language for the FAQ (default: 'de'). :returntype: string The response contains an array of objects with ``question`` and ``answer`` properties. .. _developer-ajax-controller: ArticlefaqController -------------------- .. php:class:: Wegewerk\Ai3Faq\Controller\Ajax\ArticlefaqController Backend AJAX controller (``#[AsController]``), extends ``Wegewerk\Ai3Core\Controller\Ajax\AbstractAjaxController``. .. php:method:: getFaq(ServerRequestInterface $request) Handles the AJAX FAQ generation request. #. Reads ``page_id`` and ``language`` from the POST body. #. Fetches all page content via ``PagesRepository::getPageContent()``. #. Calls ``ArticlefaqCapability`` endpoint to generate the FAQ. #. Parses the JSON response to extract question-answer pairs. #. Returns a JSON response with ``faqData``, ``source``, and ``type: 'faq'`` on success, or an error JSON on failure. :returntype: ResponseInterface .. _developer-form-engine: FormEngine integration ====================== The custom FormEngine node ``ai3FaqGeneratorElement`` is registered in TCA configuration: .. code-block:: php :caption: TCA configuration for the generator element $GLOBALS['TCA']['tt_content']['columns']['tx_ai3_faq_generator'] = [ 'exclude' => true, 'label' => 'LLL:EXT:ai3_faq/Resources/Private/Language/locallang.xlf:tx_ai3.faq.generator', 'config' => [ 'type' => 'user', 'renderType' => 'ai3FaqGeneratorElement', ], ]; .. php:class:: Wegewerk\Ai3Faq\FormEngine\Ai3FaqGeneratorElement Extends ``TYPO3\CMS\Backend\Form\Element\AbstractFormElement``. Renders a ``