Created
January 30, 2018 11:00
-
-
Save h3nn3s/866dd7fae0696c8c9d762789281a88ea to your computer and use it in GitHub Desktop.
TYPO3 powermail DataProcessor: Convert checkbox positions to there decimal represenation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace HenrikZiegenhain\MyExt\DataProcessor; | |
/*************************************************************** | |
* Copyright notice | |
* | |
* (c) 2018 Henrik Ziegenhain <[email protected]> | |
* All rights reserved | |
* | |
* This script is part of the TYPO3 project. The TYPO3 project is | |
* free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* The GNU General Public License can be found at | |
* http://www.gnu.org/copyleft/gpl.html. | |
* | |
* This script is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* This copyright notice MUST APPEAR in all copies of the script! | |
***************************************************************/ | |
use In2code\Powermail\DataProcessor\AbstractDataProcessor; | |
use In2code\Powermail\Domain\Model\Mail; | |
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser; | |
use TYPO3\CMS\Extbase\Utility\DebuggerUtility; | |
/** | |
* Class ConvertApplicationAreaValuesToBinary | |
* @package HenrikZiegenhain\MyExt\DataProcessor | |
*/ | |
class ConvertApplicationAreaValuesToBinaryDataProcessor extends AbstractDataProcessor | |
{ | |
/** | |
* @var Mail | |
*/ | |
protected $mail; | |
/** | |
* Convert values | |
*/ | |
public function convertApplicationAreaValuesToBinaryDataProcessor() | |
{ | |
// Settings und Konfigurationen | |
$settings = $this->getSettings(); | |
$configuration = $this->getConfiguration(); | |
// Die eigentliche uid des PowerMail-Formulars | |
$powerMailFormUid = $settings['main']['form']; | |
// Die spezielle Konfiguration für dieses Formular, falls vorhanden | |
$mailformConfig = $configuration[$powerMailFormUid]; | |
// Wenn keine Konfiguration vorhanden, dann Abbruch! | |
if ($mailformConfig['active'] !== '1') return; | |
// Zugriff auf Formular-Daten | |
$checkboxValues = $this->getMail()->getAnswersByFieldMarker()['mycheckboxes']->getValue(); | |
$checkboxIntValue = 0; | |
foreach ($checkboxValues as $checkboxValue) { | |
$checkboxIntValue += (int)$checkboxValue; | |
} | |
$this->getMail()->getAnswersByFieldMarker()['mycheckboxes']->setValue($checkboxIntValue); | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugin.tx_powermail.settings.setup { | |
dataProcessors { | |
30 { | |
class = HenrikZiegenhain\MyExt\DataProcessor\ConvertApplicationAreaValuesToBinaryDataProcessor | |
config { | |
# this key represents the FORM UID, where to activate the DataProcessor | |
8 { | |
active = 1 | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment