Skip to content

Commit

Permalink
Merge pull request #5 from clickstorm/TYPO3-12
Browse files Browse the repository at this point in the history
Merge in branch Typo3-12
  • Loading branch information
akoenig-clickstorm authored Aug 28, 2023
2 parents f7c57ff + b05347e commit 83275a3
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 78 deletions.
18 changes: 3 additions & 15 deletions Classes/Domain/Model/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 3 additions & 15 deletions Classes/Domain/Model/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 4 additions & 6 deletions Classes/Domain/Validator/GdprAcceptedValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Clickstorm\CsPowermailGdpr\EventListener;

use Clickstorm\CsPowermailGdpr\Domain\Model\Mail;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use In2code\Powermail\Events\FormControllerCreateActionBeforeRenderViewEvent;

class FormControllerCreateActionBeforeRenderViewEventListener
{
public function __invoke(FormControllerCreateActionBeforeRenderViewEvent $event)
{
$mail = $event->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;
}
}
6 changes: 6 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ services:

Clickstorm\CsPowermailGdpr\:
resource: '../Classes/*'

Clickstorm\CsPowermailGdpr\EventListener\FormControllerCreateActionBeforeRenderViewEventListener:
tags:
- name: event.listener
identifier: 'csPowermailGdprFormControllerCreateActionBeforeRenderViewEventListener'
event: In2code\Powermail\Events\FormControllerCreateActionBeforeRenderViewEvent
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugin.tx_powermail {
50 {
class = Clickstorm\CsPowermailGdpr\Domain\Validator\GdprAcceptedValidator
config {
foo = bla
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"typo3-ter/cs_powermail_gdpr": "*"
},
"require": {
"typo3/cms-core": "^11.5",
"in2code/powermail": "^9.0 || ^10.1"
"typo3/cms-core": "^12",
"in2code/powermail": "^11 || dev-main"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
'author_email' => '[email protected]',
'author_company' => 'clickstorm GmbH',
'state' => 'beta',
'version' => '3.1.5',
'version' => '4.0.0',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-11.5.99'
'typo3' => '',
'powermail' => ''
],
'conflicts' => [
],
Expand Down
53 changes: 15 additions & 38 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
<?php

defined('TYPO3') || die('Access denied.');
defined('TYPO3') || die();

/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class
);
(function () {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:powermail/Resources/Private/Language/locallang.xlf'][]
= 'EXT:cs_powermail_gdpr/Resources/Private/Language/locallang.xlf';

$signalSlotDispatcher->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
);
// 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,
];
})();

0 comments on commit 83275a3

Please sign in to comment.