The static export replaced every EXT:form form with a contact notice. The forms are back, rendered by TYPO3 13 and embedded in the static pages: - Page type 1704 (/<page>/form) renders only the form plugin of a page, inside a .form-island element. Every form posts to that URL (renderingOptions.additionalParams), because on www the page URL is a static file that never reaches TYPO3. htmx swaps the island in place: validation errors, multi-step pages and confirmations. A redirect to an htmx request becomes HX-Redirect (HtmxRedirectMiddleware), so Redirect finishers send the browser to the thank-you page. - While a request runs, an overlay with a spinner (as in MyE&P) covers the form. Styled inside the island: the static pages load the CSS of the TYPO3 10 export. - The bw_captcha image comes from /<page>/captcha for the same reason. Both suffixes are in the PageType enhancer of every site with forms (semesterende gets one with default '' to keep its URLs). - Ported from TYPO3 10: form setup, templates and partials, the MyE&P address finisher, the job application finisher with the MyE&P Team API client (epTeamApi* in secrets.php), the page URL/referrer finisher with ReferrerMiddleware (?ref=), the e-mail layout without the system footer, bw_captcha 5 and form_element_linked_checkbox 6. The address check forms are dropped. - German language packs (EXT:form messages): availableLanguages = de, fetched on every deploy (typo3:language:update). - The checkbox partials passed null to VHS' substring, which PHP 8.5 reports as deprecated. - DDEV no longer turns deprecations into exceptions, matching production: EXT:form's RenderFormValueViewHelper uses null as an array offset for empty optional fields (core bug, also in 13.4.37). The static pages get their placeholders from the exporter in EP/website, see .ddev/plans/static-export-form-islands.patch (local only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
75 lines
2.7 KiB
PHP
75 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace EP\EpTheme\Form;
|
|
|
|
use EP\EpProducts\EpTeam\ApiClient;
|
|
use TYPO3\CMS\Core\Routing\PageArguments;
|
|
use TYPO3\CMS\Core\Site\Entity\Site;
|
|
|
|
/**
|
|
* Sends job applications to MyE&P Team (POST /api/application-forms).
|
|
*/
|
|
class ApplicationApiFinisher extends AbstractMappedFinisher
|
|
{
|
|
public function __construct(private readonly ApiClient $apiClient) {}
|
|
|
|
protected function executeInternal()
|
|
{
|
|
try {
|
|
$payload = $this->buildPayload();
|
|
if ([] === $payload) {
|
|
$this->logWarning('Application form API finisher skipped: the mapping produced no values.');
|
|
|
|
return;
|
|
}
|
|
|
|
$formDefinition = $this->finisherContext->getFormRuntime()->getFormDefinition();
|
|
$formLabel = trim($formDefinition->getLabel());
|
|
|
|
$payload['form'] = $formDefinition->getIdentifier();
|
|
// The name the editor gave the form, so the receiving side can label a submission
|
|
// without keeping a list of identifiers. Taken from the definition rather than
|
|
// through TranslationService: a translated label would differ per site language.
|
|
$payload['formLabel'] = '' !== $formLabel ? $formLabel : $formDefinition->getIdentifier();
|
|
$payload['submittedAt'] = (new \DateTimeImmutable())->format(\DateTimeInterface::ATOM);
|
|
$payload = array_merge($payload, $this->resolvePageContext());
|
|
$payload['details'] = $this->buildLabeledValues();
|
|
|
|
$this->apiClient->submitApplicationForm($payload);
|
|
} catch (\Throwable $e) {
|
|
$this->logWarning('Application form API finisher request failed.', [
|
|
'exception' => $e,
|
|
]);
|
|
}
|
|
}
|
|
|
|
private function resolvePageContext(): array
|
|
{
|
|
$request = $this->finisherContext->getRequest();
|
|
$routing = $request->getAttribute('routing');
|
|
if (!$routing instanceof PageArguments) {
|
|
return [];
|
|
}
|
|
|
|
$pageUid = $routing->getPageId();
|
|
$context = ['pageUid' => $pageUid];
|
|
|
|
try {
|
|
/** @var Site $site */
|
|
$site = $request->getAttribute('site');
|
|
// The page itself, not the form page type the submission was posted to
|
|
$context['pageUrl'] = (string)$site->getRouter()->generateUri($pageUid, [
|
|
'_language' => $request->getAttribute('language'),
|
|
]);
|
|
} catch (\Throwable $e) {
|
|
// An unroutable page must not cost the submission, so the uid is sent without a URL.
|
|
$this->logWarning('Application form API finisher could not resolve the page URL.', [
|
|
'pageUid' => $pageUid,
|
|
'exception' => $e,
|
|
]);
|
|
}
|
|
|
|
return $context;
|
|
}
|
|
}
|