Page 1 of 1

Replacements in 4.0.0

Posted: Tue Mar 10, 2009 10:07 am
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

Re: Replacements in 4.0.0

Posted: Tue Mar 10, 2009 4:44 pm
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.

Re: Replacements in 4.0.0

Posted: Wed Mar 11, 2009 12:08 pm
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 ??

Re: Replacements in 4.0.0

Posted: Wed Mar 11, 2009 5:34 pm
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.

Re: Replacements in 4.0.0

Posted: Wed Apr 22, 2009 7:16 pm
by Mute
Has this been added to the latest release and if so, how do I use it?

Re: Replacements in 4.0.0

Posted: Wed Apr 22, 2009 7:18 pm
by Mute
Don't worry, seem to have found it!

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