chore: copy ep_products and ep_theme from EP/website@9593cc8
Copied unchanged from public/typo3conf/ext/ of EP/website at 9593cc8631354f8a363d6609de8b7433f669a9a0 (Git-tracked files only). History stays in the old repository. Only composer.json files are added so the extensions install as path packages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
59afaecea1
commit
a46918de9d
778 files changed
+67000
-2
No files matched your search
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use EP\EpProducts\EpTeam\ApiClient;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
class ApplicationApiFinisher extends AbstractMappedFinisher
|
||||
{
|
||||
/**
|
||||
* @var ApiClient
|
||||
*/
|
||||
protected $apiClient;
|
||||
|
||||
/**
|
||||
* @param ApiClient $apiClient
|
||||
*/
|
||||
public function injectApiClient(ApiClient $apiClient)
|
||||
{
|
||||
$this->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The page the form was submitted from. The URL is generated through the site router in the
|
||||
* visitor's language, the same way AddReferrerFinisher does it, so it is the page's canonical
|
||||
* URL rather than the submit request with its form arguments attached.
|
||||
*/
|
||||
private function resolvePageContext(): array
|
||||
{
|
||||
if (false === isset($GLOBALS['TSFE']) || 0 === (int)$GLOBALS['TSFE']->id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$pageUid = (int)$GLOBALS['TSFE']->id;
|
||||
$context = ['pageUid' => $pageUid];
|
||||
|
||||
try {
|
||||
$site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageUid);
|
||||
$context['pageUrl'] = (string)$site->getRouter()->generateUri($pageUid, [
|
||||
'_language' => $GLOBALS['TSFE']->getLanguage(),
|
||||
]);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user