Two work packages, one deploy.
Workbook field mapping completed (2026-09-18)
- highlights <- g:Technical Highlight (new spec-row component of the
full agency delivery; composeGroup() is generic, no change needed)
- applications <- g:Why Choose Card (benefit cards as one block)
- seometa <- new composed source x:seometa (Introduction body trimmed
at a word boundary to ~155 chars - the SEO sheet ships no meta
description, a trimmed intro beats an empty tag)
- teaser stays the hero one-liner, settling the varchar(255) question
- fix: "Save mapping" now merges over the stored mapping instead of
overwriting it - an empty dropdown no longer wipes a stored selector
Product model: solutions relation and Resources tab (2026-09-24)
- closes the gaps the full workbook walkthrough exposed (rows the
import deliberately skips because the model had no place for them)
- solutions: MM multi select to tx_vitec_domain_model_solution
(tx_vitec_product_solution_mm, relatedprodukt pattern), emitted by
both product renderers as solution cards in the shared shape
- Resources tab: inline child table tx_vitec_product_resource - per
entry a type (documentation/support), an editable card title/text,
an icon (free text with a value-picker seed set) and one link
(page/url/file/record via the link wizard). Deliberately no Extbase
model: only the UserFunc path reads the rows.
- datasheets: own MM selection of download records below the resource
list (tx_vitec_product_datasheet_mm); emitted into the SAME
resources envelope as ready-made type=datasheet cards (title/teaser/
icon from the record, url = the public /download/<slug> route, uid
fallback - private/hidden downloads 404 as everywhere)
- JSON `resources` (detail payload only, like heroimage): list envelope
{layout, items[]}; a hand-written card whose link is empty or
unresolvable is not emitted; layout switches to carousel above three
cards in total
- solutions hybrid (same day, after analysing all 100 workbooks: their
Solution Cards reference the 8 GROUPS in 98% of cases): new is_group
flag on the solution model, new idempotent CLI
vitec:create-solution-groups (8 group records; title source is
AlignSolutionsCommand::TARGET - now public -, category = the group's
own category, detail_page = the /solutions group page with -N
disambiguation). Group records are invisible to the solution list
and to vitec:align-solutions and only selectable in the product
relation; product solution cards carry isGroup
- spec raised to v1.18 (7.15 member table, 7.13.3 note, revision row;
the footer had been stuck at v1.15 since 1.16/1.17)
Requires on the server:
vendor/bin/typo3 database:updateschema "*.add,*.change"
vendor/bin/typo3 cache:flush
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
200 lines
7.4 KiB
PHP
200 lines
7.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Evomedien\Vitec\UserFunc;
|
|
|
|
use Doctrine\DBAL\ParameterType;
|
|
use Evomedien\Vitec\Service\LinkResolver;
|
|
use Evomedien\Vitec\Service\RteResolver;
|
|
use Evomedien\Vitec\Service\UsecaseSerializer;
|
|
use TYPO3\CMS\Core\Attribute\AsAllowedCallable;
|
|
use TYPO3\CMS\Core\Database\ConnectionPool;
|
|
use TYPO3\CMS\Core\Service\FlexFormService;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
|
|
|
/**
|
|
* UserFunc: render all VITEC solutions as JSON (headless).
|
|
*
|
|
* Output under content.solutions:
|
|
* { "layout": "grid|list|carousel|50-50", "solutions": [ … ] }
|
|
*
|
|
* This is the Solution counterpart the architecture spec asks for in clause
|
|
* 7.13.2 - deliberately the same shape as the market list, so the front end can
|
|
* serve both with one component.
|
|
*
|
|
* Selection semantics (FlexForm `settings.solutions`):
|
|
* - nothing selected -> ALL visible solutions, alphabetical by title
|
|
* (tx_vitec_domain_model_solution has no `sorting` column, same as market)
|
|
* - solutions selected -> exactly those, in the order the editor arranged
|
|
* them in the FlexForm
|
|
*
|
|
* The page carrying the plugin is never used as a filter.
|
|
*
|
|
* Each item uses the same shape as the card payload (ModelcardJsonRenderer,
|
|
* model type "solution") and carries `detailUrl`, resolved from the record's
|
|
* own `detail_page`. Image resolution is delegated to
|
|
* UsecaseSerializer::image() rather than re-implemented inline (clause 9.2).
|
|
*
|
|
* `render()` = top-level plugin / page discovery. `renderForRecord()` = one
|
|
* specific tt_content row (reused by ContainerChildrenProcessor for nested
|
|
* plugins). Exception-safe.
|
|
*/
|
|
class SolutionListJsonRenderer
|
|
{
|
|
private ?ContentObjectRenderer $cObj = null;
|
|
|
|
/**
|
|
* TYPO3 v14 hands the ContentObjectRenderer over through this setter only -
|
|
* ContentObjectRenderer::callUserFunction() duck-types it with
|
|
* is_callable([$classObj, 'setContentObjectRenderer']). Without the method
|
|
* $this->cObj stays null, the cObj branch of render() never fires and the
|
|
* call falls through to page discovery, which picks the FIRST element of
|
|
* this CType on the page rather than the one actually being rendered.
|
|
*/
|
|
public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
|
|
{
|
|
$this->cObj = $cObj;
|
|
}
|
|
|
|
private const TABLE = 'tx_vitec_domain_model_solution';
|
|
private const CTYPE = 'vitec_solutionlist';
|
|
|
|
#[AsAllowedCallable]
|
|
public function render(string $content, array $conf): string
|
|
{
|
|
$row = is_array($this->cObj?->data ?? null) ? $this->cObj->data : null;
|
|
if ($row && (string)($row['CType'] ?? '') === self::CTYPE) {
|
|
return $this->renderForRecord($row);
|
|
}
|
|
|
|
$pageId = 0;
|
|
$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
|
|
if ($request !== null) {
|
|
$pageInfo = $request->getAttribute('frontend.page.information');
|
|
if ($pageInfo !== null) {
|
|
$pageId = (int)$pageInfo->getId();
|
|
}
|
|
}
|
|
if ($pageId <= 0) {
|
|
$pageId = (int)($GLOBALS['TSFE']->id ?? 0);
|
|
}
|
|
if ($pageId <= 0) {
|
|
return '';
|
|
}
|
|
|
|
$qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
|
|
$ces = $qb
|
|
->select('*')
|
|
->from('tt_content')
|
|
->where(
|
|
$qb->expr()->eq('pid', $qb->createNamedParameter($pageId, ParameterType::INTEGER)),
|
|
$qb->expr()->eq('CType', $qb->createNamedParameter(self::CTYPE, ParameterType::STRING)),
|
|
$qb->expr()->eq('deleted', 0),
|
|
$qb->expr()->eq('hidden', 0)
|
|
)
|
|
->executeQuery()
|
|
->fetchAllAssociative();
|
|
|
|
if (empty($ces)) {
|
|
return '';
|
|
}
|
|
|
|
return $this->renderForRecord($ces[0]);
|
|
}
|
|
|
|
/**
|
|
* @param array<string,mixed> $contentElement
|
|
*/
|
|
public function renderForRecord(array $contentElement): string
|
|
{
|
|
try {
|
|
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
|
|
$flexFormData = $flexFormService->convertFlexFormContentToArray($contentElement['pi_flexform'] ?? '');
|
|
$settings = $flexFormData['settings'] ?? [];
|
|
|
|
$layout = (string)($settings['layout'] ?? 'grid');
|
|
$debugMode = (bool)($settings['debug'] ?? false);
|
|
$selectedUids = GeneralUtility::intExplode(',', (string)($settings['solutions'] ?? ''), true);
|
|
|
|
// Always fetch the full (small) table once - that way a selected
|
|
// record that has meanwhile been hidden or deleted simply drops out.
|
|
$qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE);
|
|
$rows = $qb
|
|
->select('*')
|
|
->from(self::TABLE)
|
|
->where(
|
|
$qb->expr()->eq('deleted', 0),
|
|
$qb->expr()->eq('hidden', 0),
|
|
// Group-level records (hybrid 2026-09-24) exist for the
|
|
// product relation - never as a 40th+ list entry.
|
|
$qb->expr()->eq('is_group', 0)
|
|
)
|
|
->orderBy('title', 'ASC')
|
|
->executeQuery()
|
|
->fetchAllAssociative();
|
|
|
|
$serializer = GeneralUtility::makeInstance(UsecaseSerializer::class);
|
|
|
|
if ($selectedUids === []) {
|
|
$solutions = array_map(
|
|
fn(array $r): array => $this->serializeSolution($r, $serializer),
|
|
$rows
|
|
);
|
|
} else {
|
|
// Keep the editor's FlexForm order. A SQL IN() would return the
|
|
// rows in storage order, so the sequence is rebuilt here.
|
|
$byUid = [];
|
|
foreach ($rows as $r) {
|
|
$byUid[(int)$r['uid']] = $r;
|
|
}
|
|
$solutions = [];
|
|
foreach ($selectedUids as $uid) {
|
|
if (isset($byUid[$uid])) {
|
|
$solutions[] = $this->serializeSolution($byUid[$uid], $serializer);
|
|
}
|
|
}
|
|
}
|
|
|
|
$response = [
|
|
'layout' => $layout,
|
|
'showToolbar' => (bool)($settings['showtoolbar'] ?? false),
|
|
'solutions' => $solutions,
|
|
];
|
|
|
|
if ($debugMode) {
|
|
$response['debug'] = [
|
|
'count' => count($solutions),
|
|
'selected' => $selectedUids,
|
|
'settings' => $settings,
|
|
];
|
|
}
|
|
|
|
return (string)json_encode($response);
|
|
} catch (\Throwable $e) {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param array<string,mixed> $r
|
|
* @return array<string,mixed>
|
|
*/
|
|
private function serializeSolution(array $r, UsecaseSerializer $serializer): array
|
|
{
|
|
$uid = (int)$r['uid'];
|
|
|
|
return [
|
|
'uid' => $uid,
|
|
'title' => (string)($r['title'] ?? ''),
|
|
'slug' => (string)($r['slug'] ?? ''),
|
|
'subtitle' => (string)($r['subtitle'] ?? ''),
|
|
'teaser' => (string)($r['teaser'] ?? ''),
|
|
'description' => RteResolver::html($r['description'] ?? ''),
|
|
'detailUrl' => LinkResolver::pageUrl((int)($r['detail_page'] ?? 0)),
|
|
'image' => $serializer->image($uid, 'image', self::TABLE, true),
|
|
];
|
|
}
|
|
}
|