From fc07204062f375ff11b631877798d7806ad4a600 Mon Sep 17 00:00:00 2001 From: mhirdes Date: Tue, 2 May 2023 11:43:32 +0200 Subject: [PATCH 1/4] Update ext_emconf.php --- ext_emconf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext_emconf.php b/ext_emconf.php index e118103..4b125b4 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,10 +8,10 @@ 'author_email' => 'hirdes@clickstorm.de', 'author_company' => 'clickstorm GmbH', 'state' => 'beta', - 'version' => '3.1.4', + 'version' => '4.0.0-dev', 'constraints' => [ 'depends' => [ - 'typo3' => '11.5.0-11.5.99' + 'typo3' => '' ], 'conflicts' => [ ], From 258bee42662296f88048167aefeb277b82ed6adc Mon Sep 17 00:00:00 2001 From: mhirdes Date: Tue, 2 May 2023 11:47:04 +0200 Subject: [PATCH 2/4] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dcdd05d..252b576 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ }, "require": { "typo3/cms-core": "^12", - "in2code/powermail": "^11" + "in2code/powermail": "^11 || dev-main" }, "autoload": { "psr-4": { From e1f711251d7593bf0558957d62ab750ede1db233 Mon Sep 17 00:00:00 2001 From: mhirdes Date: Tue, 2 May 2023 14:25:30 +0200 Subject: [PATCH 3/4] [FEATURE] use PSR-14 events --- .../Validator/GdprAcceptedValidator.php | 10 ++--- ...ateActionBeforeRenderViewEventListener.php | 25 +++++++++++ ...irmActionBeforeRenderViewEventListener.php | 16 +++++++ Configuration/Services.yaml | 13 ++++++ ext_localconf.php | 44 +++---------------- 5 files changed, 63 insertions(+), 45 deletions(-) create mode 100644 Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php create mode 100644 Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php diff --git a/Classes/Domain/Validator/GdprAcceptedValidator.php b/Classes/Domain/Validator/GdprAcceptedValidator.php index 6da8489..2d739fa 100644 --- a/Classes/Domain/Validator/GdprAcceptedValidator.php +++ b/Classes/Domain/Validator/GdprAcceptedValidator.php @@ -42,22 +42,20 @@ class GdprAcceptedValidator extends AbstractValidator * @param Mail $mail * @return Result */ - public function validate($mail) + public function isValid(mixed $value): void { $result = GeneralUtility::makeInstance(Result::class); // throw error - if(!$mail->getForm()->isTxCspowermailgdprHidden()) { + if(!$value->getForm()->isTxCspowermailgdprHidden()) { $params = GeneralUtility::_GPmerged('tx_powermail_pi1'); if(isset($params['field']['tx_cspowermailgdpr_accepted']) && !$params['field']['tx_cspowermailgdpr_accepted'] - && !$mail->isTxCspowermailgdprAccepted() + && !$value->isTxCspowermailgdprAccepted() ) { $errorMarker = LocalizationUtility::translate('tx_cspowermailgdpr.checkbox.marker', 'cs_powermail_gdpr') . ':'; - $result->addError(new Error($errorMarker, 123009282, [], 'Error tx_cspowermailgdpr')); + $this->result->addError(new Error($errorMarker, 123009282, [], 'Error tx_cspowermailgdpr')); } } - - return $result; } } diff --git a/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php b/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php new file mode 100644 index 0000000..e5ef520 --- /dev/null +++ b/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php @@ -0,0 +1,25 @@ +getMail(); + if (!$mail->isTxCspowermailgdprAccepted()) { + $mail->setTxCspowermailgdprAccepted(self::checkParam()); + } + } + + public static function checkParam(): int + { + $params = GeneralUtility::_GP('tx_powermail_pi1'); + + return $params['field']['tx_cspowermailgdpr_accepted'] ? 1 : 0; + } +} diff --git a/Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php b/Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php new file mode 100644 index 0000000..8fbc681 --- /dev/null +++ b/Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php @@ -0,0 +1,16 @@ +getMail(); + $mail->setTxCspowermailgdprAccepted($this->checkParam()); + } +} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 4a3e737..8999745 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -6,3 +6,16 @@ services: Clickstorm\CsPowermailGdpr\: resource: '../Classes/*' + + Clickstorm\CsPowermailGdpr\EventListener\FormControllerCreateActionBeforeRenderViewEventListener: + tags: + - name: event.listener + identifier: 'csPowermailGdprFormControllerCreateActionBeforeRenderViewEventListener' + event: In2code\Powermail\Events\FormControllerCreateActionBeforeRenderViewEvent + + + Clickstorm\CsPowermailGdpr\EventListener\FormControllerOptinConfirmActionBeforeRenderViewEventListener: + tags: + - name: event.listener + identifier: 'csPowermailGdprFormControllerOptinConfirmActionBeforeRenderViewEventListener' + event: In2code\Powermail\Events\FormControllerOptinConfirmActionBeforeRenderViewEvent diff --git a/ext_localconf.php b/ext_localconf.php index c871db8..c376ca3 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,42 +1,8 @@ connect( - 'In2code\Powermail\Controller\FormController', - 'createActionBeforeRenderView', - 'Clickstorm\CsPowermailGdpr\Hook\FormController', - 'manipulateForm', - false -); - -$signalSlotDispatcher->connect( - 'In2code\Powermail\Controller\FormController', - 'confirmationActionBeforeRenderView', - 'Clickstorm\CsPowermailGdpr\Hook\FormController', - 'manipulateFormForConfirmation', - false -); - -$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:powermail/Resources/Private/Language/locallang.xlf'][] - = 'EXT:cs_powermail_gdpr/Resources/Private/Language/locallang.xlf'; - -// Extend models -$extbaseObjectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class); -$extbaseObjectContainer->registerImplementation( - \In2code\Powermail\Domain\Model\Form::class, - \Clickstorm\CsPowermailGdpr\Domain\Model\Form::class -); -$extbaseObjectContainer->registerImplementation( - \In2code\Powermail\Domain\Model\Mail::class, - \Clickstorm\CsPowermailGdpr\Domain\Model\Mail::class -); -$extbaseObjectContainer->registerImplementation( - \In2code\Powermail\Domain\Factory\FileFactory::class, - \Clickstorm\CsPowermailGdpr\Domain\Factory\FileFactory::class -); +(function () { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:powermail/Resources/Private/Language/locallang.xlf'][] + = 'EXT:cs_powermail_gdpr/Resources/Private/Language/locallang.xlf'; +})(); From 22ae52e3c1801db7ec8baf8f10d696eb96490a1e Mon Sep 17 00:00:00 2001 From: mhirdes Date: Fri, 12 May 2023 15:34:54 +0200 Subject: [PATCH 4/4] [BUGFIX] several modifications for TYPO3 v12 --- Classes/Domain/Model/Form.php | 18 +++--------------- Classes/Domain/Model/Mail.php | 18 +++--------------- ...eateActionBeforeRenderViewEventListener.php | 2 +- ...firmActionBeforeRenderViewEventListener.php | 16 ---------------- Configuration/Services.yaml | 7 ------- .../{constants.txt => constants.typoscript} | 0 .../TypoScript/{setup.txt => setup.typoscript} | 1 + ext_emconf.php | 3 ++- ext_localconf.php | 11 +++++++++++ 9 files changed, 21 insertions(+), 55 deletions(-) delete mode 100644 Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php rename Configuration/TypoScript/{constants.txt => constants.typoscript} (100%) rename Configuration/TypoScript/{setup.txt => setup.typoscript} (95%) diff --git a/Classes/Domain/Model/Form.php b/Classes/Domain/Model/Form.php index 1395093..e3bde07 100644 --- a/Classes/Domain/Model/Form.php +++ b/Classes/Domain/Model/Form.php @@ -2,28 +2,16 @@ namespace Clickstorm\CsPowermailGdpr\Domain\Model; -/** - * Class Form - */ class Form extends \In2code\Powermail\Domain\Model\Form { - /** - * @var bool - */ - protected $txCspowermailgdprHidden; + protected bool $txCspowermailgdprHidden = false; - /** - * @return bool - */ - public function isTxCspowermailgdprHidden() + public function isTxCspowermailgdprHidden(): bool { return $this->txCspowermailgdprHidden; } - /** - * @param bool $txCspowermailgdprHidden - */ - public function setTxCspowermailgdprHidden($txCspowermailgdprHidden) + public function setTxCspowermailgdprHidden(bool $txCspowermailgdprHidden): void { $this->txCspowermailgdprHidden = $txCspowermailgdprHidden; } diff --git a/Classes/Domain/Model/Mail.php b/Classes/Domain/Model/Mail.php index af2890d..40c8bc2 100644 --- a/Classes/Domain/Model/Mail.php +++ b/Classes/Domain/Model/Mail.php @@ -2,28 +2,16 @@ namespace Clickstorm\CsPowermailGdpr\Domain\Model; -/** - * Class Mail - */ class Mail extends \In2code\Powermail\Domain\Model\Mail { - /** - * @var bool - */ - protected $txCspowermailgdprAccepted; + protected bool $txCspowermailgdprAccepted = false; - /** - * @return bool - */ - public function isTxCspowermailgdprAccepted() + public function isTxCspowermailgdprAccepted(): bool { return $this->txCspowermailgdprAccepted; } - /** - * @param bool $txCspowermailgdprAccepted - */ - public function setTxCspowermailgdprAccepted($txCspowermailgdprAccepted) + public function setTxCspowermailgdprAccepted(bool $txCspowermailgdprAccepted): void { $this->txCspowermailgdprAccepted = $txCspowermailgdprAccepted; } diff --git a/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php b/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php index e5ef520..8de7533 100644 --- a/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php +++ b/Classes/EventListener/FormControllerCreateActionBeforeRenderViewEventListener.php @@ -4,7 +4,7 @@ use Clickstorm\CsPowermailGdpr\Domain\Model\Mail; use TYPO3\CMS\Core\Utility\GeneralUtility; -use In2code\Powermail\Controller\FormControllerCreateActionBeforeRenderViewEvent; +use In2code\Powermail\Events\FormControllerCreateActionBeforeRenderViewEvent; class FormControllerCreateActionBeforeRenderViewEventListener { diff --git a/Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php b/Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php deleted file mode 100644 index 8fbc681..0000000 --- a/Classes/EventListener/FormControllerOptinConfirmActionBeforeRenderViewEventListener.php +++ /dev/null @@ -1,16 +0,0 @@ -getMail(); - $mail->setTxCspowermailgdprAccepted($this->checkParam()); - } -} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 8999745..b444612 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -12,10 +12,3 @@ services: - name: event.listener identifier: 'csPowermailGdprFormControllerCreateActionBeforeRenderViewEventListener' event: In2code\Powermail\Events\FormControllerCreateActionBeforeRenderViewEvent - - - Clickstorm\CsPowermailGdpr\EventListener\FormControllerOptinConfirmActionBeforeRenderViewEventListener: - tags: - - name: event.listener - identifier: 'csPowermailGdprFormControllerOptinConfirmActionBeforeRenderViewEventListener' - event: In2code\Powermail\Events\FormControllerOptinConfirmActionBeforeRenderViewEvent diff --git a/Configuration/TypoScript/constants.txt b/Configuration/TypoScript/constants.typoscript similarity index 100% rename from Configuration/TypoScript/constants.txt rename to Configuration/TypoScript/constants.typoscript diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.typoscript similarity index 95% rename from Configuration/TypoScript/setup.txt rename to Configuration/TypoScript/setup.typoscript index 24e1428..05b60c5 100644 --- a/Configuration/TypoScript/setup.txt +++ b/Configuration/TypoScript/setup.typoscript @@ -14,6 +14,7 @@ plugin.tx_powermail { 50 { class = Clickstorm\CsPowermailGdpr\Domain\Validator\GdprAcceptedValidator config { + foo = bla } } } diff --git a/ext_emconf.php b/ext_emconf.php index 4b125b4..95f3245 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -11,7 +11,8 @@ 'version' => '4.0.0-dev', 'constraints' => [ 'depends' => [ - 'typo3' => '' + 'typo3' => '', + 'powermail' => '' ], 'conflicts' => [ ], diff --git a/ext_localconf.php b/ext_localconf.php index c376ca3..b6ede80 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -5,4 +5,15 @@ (function () { $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:powermail/Resources/Private/Language/locallang.xlf'][] = 'EXT:cs_powermail_gdpr/Resources/Private/Language/locallang.xlf'; + + // use XClasses instead of sublcasses + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\In2code\Powermail\Domain\Model\Mail::class] = [ + 'className' => \Clickstorm\CsPowermailGdpr\Domain\Model\Mail::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\In2code\Powermail\Domain\Model\Form::class] = [ + 'className' => \Clickstorm\CsPowermailGdpr\Domain\Model\Form::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\In2code\Powermail\Domain\Factory\FileFactory::class] = [ + 'className' => \Clickstorm\CsPowermailGdpr\Domain\Factory\FileFactory::class, + ]; })();