Skip to content

Commit

Permalink
[TASK] Update for powermail 2.11
Browse files Browse the repository at this point in the history
Added an example how to change the receiver of a powermail
  • Loading branch information
einpraegsam committed Oct 1, 2015
1 parent 10efbfc commit 9edecca
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
13 changes: 8 additions & 5 deletions Classes/Controller/FormController.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php
namespace In2code\Powermailextended\Controller;

use In2code\Powermail\Controller\FormController as FormControllerPowermail;
use In2code\Powermail\Domain\Model\Mail;

/**
* Using a Slot to call a Powermail Signal
* Class FormController
*
* Class FormControllerExtended
* @package In2code\Powermailextended\Controller
*/
class FormController {

/**
* @param \In2code\Powermail\Domain\Model\Mail $mail
* @param Mail $mail
* @param string $hash
* @param \In2code\Powermail\Controller\FormController $pObj
* @param FormControllerPowermail $pObj
* @return void
*/
public function manipulateMailObjectOnCreate($mail, $hash, $pObj) {
public function manipulateMailObjectOnCreate(Mail $mail, $hash, $pObj) {
foreach ($mail->getAnswers() as $answer) {
if ($answer->getValue() === 'alex') {
$answer->setValue('alexander');
Expand Down
31 changes: 31 additions & 0 deletions Classes/Domain/Service/SendMailService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace In2code\Powermailextended\Domain\Service;

use In2code\Powermail\Domain\Model\Mail;
use TYPO3\CMS\Core\Mail\MailMessage;

/**
* SendMailService
*
* @package powermailextend
*/
class SendMailService {

/**
* Manipulate message object short before powermail send the mail
*
* @param MailMessage $message
* @param array $email
* @param Mail $mail
* @param array $settings
* @param string $type Email to "sender" or "receiver"
*/
public function manipulateMail($message, $email, $mail, $settings, $type) {
// overwrite the receiver
$message->setTo(
array(
'anotheremail@domain.org' => 'receiverName'
)
);
}
}
19 changes: 17 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
<?php
// enable SignalSlot
//$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\SignalSlot\Dispatcher');
/**
* Register some Slots
*/
/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')
->get('TYPO3\\CMS\\Extbase\\SignalSlot\Dispatcher');

// Manipulate a value before sending
//$signalSlotDispatcher->connect(
// 'In2code\Powermail\Controller\FormController',
// 'createActionBeforeRenderView',
// 'In2code\Powermailextended\Controller\FormController',
// 'manipulateMailObjectOnCreate',
// FALSE
//);

// Change receiver mail
//$signalSlotDispatcher->connect(
// 'In2code\Powermail\Domain\Service\SendMailService',
// 'sendTemplateEmailBeforeSend',
// 'In2code\Powermailextended\Domain\Service\SendMailService',
// 'manipulateMail',
// FALSE
//);

0 comments on commit 9edecca

Please sign in to comment.