Formular-Infrastruktur: Contact/Demo/Helpdesk mit E-Mail- und Salesforce-Delivery, JSON-Renderer-Erweiterungen, Crop-Variants

Build-Artefakte in public/_frontend/assets nicht enthalten.
This commit is contained in:
orasche committed 2026-07-30 13:12:45 +02:00
1 parent eae40f4286
commit a739dd8fe3
51 files changed
+1598 -303

No files matched your search

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Evomedien\Vitec\Forms\Delivery;
/**
* Delivery strategy for VITEC form submissions.
* Implementations MUST throw on failure — the middleware logs the error
* on the stored submission and keeps the data safe.
*/
interface DeliveryInterface
{
/**
* @param array<string,string> $payload validated, filtered field values
* @param array<string,mixed> $settings FlexForm settings of the form plugin
*/
public function deliver(string $formKey, array $payload, array $settings): void;
}
+48
View File
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Evomedien\Vitec\Forms\Delivery;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Sends the submission as a plain-text mail to the FlexForm-configured
* recipient(s). Sender = system default (MAIL settings); reply-to = the
* submitter's email when present.
*/
final class EmailDelivery implements DeliveryInterface
{
public function deliver(string $formKey, array $payload, array $settings): void
{
$recipients = GeneralUtility::trimExplode(',', (string)($settings['recipient'] ?? ''), true);
if ($recipients === []) {
throw new \RuntimeException('No recipient configured in the form plugin (FlexForm "Recipient").');
}
$subject = trim((string)($settings['subject'] ?? ''));
if ($subject === '') {
$subject = 'VITEC website form: ' . $formKey;
}
$lines = [];
foreach ($payload as $field => $value) {
$lines[] = str_pad($field . ':', 16) . $value;
}
$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail->to(...$recipients)
->subject($subject)
->text("Form: $formKey\n\n" . implode("\n", $lines));
$submitterEmail = trim((string)($payload['email'] ?? ''));
if ($submitterEmail !== '' && filter_var($submitterEmail, FILTER_VALIDATE_EMAIL)) {
$mail->replyTo($submitterEmail);
}
if (!$mail->send()) {
throw new \RuntimeException('MailMessage::send() reported failure.');
}
}
}
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Evomedien\Vitec\Forms\Delivery;
/**
* Salesforce delivery — PREPARED STUB.
*
* The old website posted the contact form to Salesforce Web-to-Lead
* (custom field ids like 00N3z00000DCiyV). When credentials / the target
* setup are decided, implement deliver() here (Web-to-Lead POST or REST
* API) including the camelCase -> Salesforce field mapping. Until then any
* submission with delivery=salesforce is stored with status "failed" and
* this message — no data is lost.
*/
final class SalesforceDelivery implements DeliveryInterface
{
public function deliver(string $formKey, array $payload, array $settings): void
{
throw new \RuntimeException(
'Salesforce delivery is prepared but not configured yet — submission kept in the log.'
);
}
}