Replacements in 4.0.0

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
saiaman
Forum Newbie
Posts: 8
Joined: Mon Oct 06, 2008 10:03 am

Replacements in 4.0.0

Post by saiaman »

Hi,
in the older version 3.x there was a Swift_Plugin_Decorator_Replacements that can be extended in order to do such a thing :

Code: Select all

 
class XXXXX_Swift_Plugin_Replacements extends Swift_Plugin_Decorator_Replacements {
 
    function getReplacementsFor($address) {
        $encoded = urlencode("{email}");
        return array("{email}"=>$address,$encoded=>$address);
    }
}

Is there anything like this in 4.0.0 or how can i manage such replacements without making a huge array of replacements?

Thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Replacements in 4.0.0

Post by Chris Corbyn »

Until yesterday I didn't realise I'd missed this feature out... small oversight on my part.

It will probably find it's way into 4.0.1 since this is a regression.

I'll probably be releasing 4.0.1 today or tomorrow (to be honest, the bug reports following the 280 downloads in this period have been nearly non-existent, which is great, I hope :P). It's more little additions like this.
saiaman
Forum Newbie
Posts: 8
Joined: Mon Oct 06, 2008 10:03 am

Re: Replacements in 4.0.0

Post by saiaman »

Solution is easy i think :

instead of using :

Code: Select all

$this->_replacements[$address]
On line 87

let's create a method

Code: Select all

 public function getReplacementsFor($address){
    if(isset($this->_replacements[$address])){
        return $this->_replacements[$address];
    }
    return null;
  }
and then replace old 87 -> 89 lines by :

Code: Select all

   $replacements = $this->getReplacementsFor($address); 
    if (!is_null(replacements ))
    {
Am i right ??
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Replacements in 4.0.0

Post by Chris Corbyn »

Yeah something along those lines. I'll definitely be adding it.

I was considering just making it easy to subclass the plugin and override a lookupReplcacements() method or something but to be honest, that would be my lazy approach... composition is always better than inheritance.

Probably will have added this by Friday.
Mute
Forum Newbie
Posts: 15
Joined: Mon Jul 10, 2006 9:02 am

Re: Replacements in 4.0.0

Post by Mute »

Has this been added to the latest release and if so, how do I use it?
Mute
Forum Newbie
Posts: 15
Joined: Mon Jul 10, 2006 9:02 am

Re: Replacements in 4.0.0

Post by Mute »

Don't worry, seem to have found it!

http://swiftmailer.org/docs/decorator-plugin
Post Reply