Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions Classes/Finishers/BrevoFinisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

/**
* Finisher for EXT:form sending the data to brevo
Expand All @@ -32,20 +33,28 @@ class BrevoFinisher extends AbstractFinisher implements LoggerAwareInterface
{
use LoggerAwareTrait;

/** @var Configuration */
protected Configuration $extensionConfiguration;
protected ?Configuration $extensionConfiguration = null;

/** @var EventDispatcherInterface */
protected $eventDispatcher;

public function __construct(string $finisherIdentifier = '')
{
$this->extensionConfiguration = new Configuration();
try {
$this->extensionConfiguration = new Configuration();
} catch (\RuntimeException $e) {
$this->logger?->error('Brevo finisher skipped: ' . $e->getMessage());
}
$this->eventDispatcher = GeneralUtility::makeInstance(EventDispatcher::class);
}

protected function executeInternal(): void
{
if ($this->extensionConfiguration === null) {
$this->setFinisherSubscribedVariable(0);
return;
}

if (!$this->newsletterSubscriptionIsEnabled()) {
$this->setFinisherSubscribedVariable(0);
return;
Expand Down Expand Up @@ -177,7 +186,11 @@ protected function getRedirectionUrl(): string
'parameter' => $this->getDoiRedirectPageId(),
'forceAbsoluteUrl' => true,
];
return $this->getTypoScriptFrontendController()->cObj->typoLink_URL($typolinkConfiguration);
// TYPO3 v14: AbstractFinisher::getTypoScriptFrontendController() was removed and
// ContentObjectRenderer::typoLink_URL() is superseded by createUrl().
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$contentObjectRenderer->setRequest($this->finisherContext->getRequest());
return $contentObjectRenderer->createUrl($typolinkConfiguration);
}

protected function getApi(): ContactsApi
Expand Down
10 changes: 10 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ services:
autoconfigure: true
public: false

# Finisher is instantiated via GeneralUtility::makeInstance() from
# FormDefinition::createFinisher(). Without an explicit service registration it
# is invisible to the container, so the inject* setters of AbstractFinisher
# (translationService, viewFactory) never run and submitting the form fatals
# with "Typed property ...::$translationService must not be accessed before
# initialization". public: true keeps it in the container graph (no pruning)
# and ensures the setters are applied.
StudioMitte\Brevo\Finishers\BrevoFinisher:
public: true

StudioMitte\Brevo\Command\TestCommand:
tags:
- name: 'console.command'
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"GPL-2.0-or-later"
],
"require": {
"typo3/cms-core": "^11.5||^12.4 || ^13.4",
"typo3/cms-form": "^11.5||^12.4 || ^13.4",
"typo3/cms-core": "^11.5||^12.4 || ^13.4 || ^14.3",
"typo3/cms-form": "^11.5||^12.4 || ^13.4 || ^14.3",
"getbrevo/brevo-php": "^1"
},
"require-dev": {
Expand Down