TYPO3  7.6
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Swift_Plugins_DecoratorPlugin Class Reference
Inheritance diagram for Swift_Plugins_DecoratorPlugin:
Swift_Events_SendListener Swift_Plugins_Decorator_Replacements Swift_Events_EventListener

Public Member Functions

 __construct ($replacements)
 
 setReplacements ($replacements)
 
 beforeSendPerformed (Swift_Events_SendEvent $evt)
 
 getReplacementsFor ($address)
 
 sendPerformed (Swift_Events_SendEvent $evt)
 

Private Member Functions

 _restoreMessage (Swift_Mime_Message $message)
 

Private Attributes

 $_replacements
 
 $_originalBody
 
 $_originalHeaders = array()
 
 $_originalChildBodies = array()
 
 $_lastMessage
 

Detailed Description

Allows customization of Messages on-the-fly.

Author
Chris Corbyn
Fabien Potencier

Definition at line 17 of file DecoratorPlugin.php.

Constructor & Destructor Documentation

__construct (   $replacements)

Create a new DecoratorPlugin with $replacements.

The $replacements can either be an associative array, or an implementation of Swift_Plugins_Decorator_Replacements.

When using an array, it should be of the form: $replacements = array( "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") )

When using an instance of Swift_Plugins_Decorator_Replacements, the object should return just the array of replacements for the address given to Swift_Plugins_Decorator_Replacements::getReplacementsFor().

Parameters
mixed$replacementsArray or Swift_Plugins_Decorator_Replacements

Definition at line 54 of file DecoratorPlugin.php.

References setReplacements().

Member Function Documentation

_restoreMessage ( Swift_Mime_Message  $message)
private

Restore a changed message back to its original state

Definition at line 179 of file DecoratorPlugin.php.

References $_originalHeaders, Swift_Mime_MimeEntity\getChildren(), Swift_Mime_MimeEntity\getHeaders(), and Swift_Mime_MimeEntity\setBody().

Referenced by beforeSendPerformed(), and sendPerformed().

beforeSendPerformed ( Swift_Events_SendEvent  $evt)

Invoked immediately before the Message is sent.

Parameters
Swift_Events_SendEvent$evt

Implements Swift_Events_SendListener.

Definition at line 80 of file DecoratorPlugin.php.

References _restoreMessage(), Swift_Events_SendEvent\getMessage(), and getReplacementsFor().

getReplacementsFor (   $address)

Find a map of replacements for the address.

If this plugin was provided with a delegate instance of Swift_Plugins_Decorator_Replacements then the call will be delegated to it. Otherwise, it will attempt to find the replacements from the array provided in the constructor.

If no replacements can be found, an empty value (NULL) is returned.

Parameters
string$address
Returns
array

Implements Swift_Plugins_Decorator_Replacements.

Definition at line 156 of file DecoratorPlugin.php.

Referenced by beforeSendPerformed().

sendPerformed ( Swift_Events_SendEvent  $evt)

Invoked immediately after the Message is sent.

Parameters
Swift_Events_SendEvent$evt

Implements Swift_Events_SendListener.

Definition at line 173 of file DecoratorPlugin.php.

References _restoreMessage(), and Swift_Events_SendEvent\getMessage().

setReplacements (   $replacements)

Sets replacements.

Parameters
mixed$replacementsArray or Swift_Plugins_Decorator_Replacements
See Also
__construct()

Definition at line 66 of file DecoratorPlugin.php.

Referenced by __construct().

Member Data Documentation

$_lastMessage
private

The Message that was last replaced

Definition at line 32 of file DecoratorPlugin.php.

$_originalBody
private

The body as it was before replacements

Definition at line 23 of file DecoratorPlugin.php.

$_originalChildBodies = array()
private

Bodies of children before they are replaced

Definition at line 29 of file DecoratorPlugin.php.

$_originalHeaders = array()
private

The original headers of the message, before replacements

Definition at line 26 of file DecoratorPlugin.php.

Referenced by _restoreMessage().

$_replacements
private

The replacement map

Definition at line 20 of file DecoratorPlugin.php.