Hi Arvydas,
to support Andreas' idea, is it possible to make a minor change to _sendMail()
as in the code below? Or is there some reason why this is not backward
compatible ?
protected $_sActMailFunctionCall = "";
protected $_aActMailFunctionParams = null;
protected $_blExcuteMailFunctionCall = false;
protected $_sActMailFunctionResult = "";
protected function _sendMail()
{
if ( $this->_blExcuteMailFunctionCall == true ) {
$this->_executeSendMailFunction();
}
$blResult = false;
try {
$blResult = parent::send();
} catch( Exception $oEx ) {
}
return $blResult;
}
public function setupSendMailFunction( $sFunction, $aParams,
$blCallFunction
= true )
{
$this->_sActMailFunctionCall = $sFunction;
$this->_aActMailFunctionParams = $aParams;
$this->_blExcuteMailFunctionCall = $blCallFunction;
}
public function getSendMailFunctionResult()
{
return $this->_sActMailFunctionResult;
}
protected function _executeSendMailFunction()
{
$this->_sActMailFunctionResult =
call_user_func_array( array( $this, $this->_sActMailFunctionCall ),
$this->_aActMailFunctionParams );
}
Regards,
Chris Jolly
Ontraq Europe
________________________________
From: Arvydas <[email protected]>
To: [email protected]
Sent: Wed, November 10, 2010 8:08:04 AM
Subject: Re: [oxid-dev-general] oxemail: put function calls
intoproperty[T-D3898PM6XJ-46]
Will it be a huge switch? I'm interested about implementation..
Best regards,
Arvydas Vapsva
--------------------------------------------------
From: "anzido GmbH" <[email protected]>
Sent: Saturday, November 06, 2010 11:32 AM
To: <[email protected]>
Subject: Re: [oxid-dev-general] oxemail: put function calls
intoproperty[T-D3898PM6XJ-46]
> Hi Arvydas,
>
> thx for your response.
>
> What exactly do you mean or want to know by:
>> The question is how will look your function which "trigger some special
>> functionality before sending an email" "dependent on the type of email"?
>
> ?
>
> Beste Grüße aus Dortmund!
> Andreas Ziethen | Geschäftsführung
>
> --
> anzido GmbH
> Kirchhörder Str. 12
> 44229 Dortmund
> Tel.: 0231 - 60 71 079
> Fax.: 0231 - 60 71 081
> Mobil:0176 - 8325 1488
> Email: [email protected]
> Web: http://www.anzido.com ( http://www.anzido.com/ )
>
> USt-ID: DE257982972
> Geschäftsführung: Andreas Ziethen
> Amtsgericht Dortmund HRB 20883
> -----Ursprüngliche Daten-----
> Datum: 14.10.2010 13:21:52
> Von: Arvydas <[email protected]>
> An: <[email protected]>
> Betreff: Re: [oxid-dev-general] oxemail: put function calls intoproperty
> Vorgang: T-D3898PM6XJ-46
>
>> Hello,
>>
>> thanks for your ideas, that's a good hint for refactoring/improving. Sadly
>> we cant just change code the way you want
>> due to compatibility with previous shop versions, thus we will improve this
>> code in next major releases.
>>
>> If you are free to change/extend your own code and able to replace current
>> mail function calls you may use a bit tuned
>> your suggested executeSendMailFunction() function:
>>
>> public function executeSendMailFunction( $sFunction, $aParams )
>> {
>> return call_user_func_array( array( $this, $sFunction ), $aParams );
>> }
>>
>> The question is how will look your function which "trigger some special
>> functionality before sending an email" "dependent on the type of email"?
>>
>> Best regards,
>> Arvydas Vapsva
>>
>> --------------------------------------------------
>> From: "anzido GmbH" <[email protected]>
>> Sent: Sunday, October 03, 2010 12:24 PM
>> To: <[email protected]>
>> Subject: [oxid-dev-general] oxemail: put function calls into
>> property[T-D3898PM6XJ-46]
>>
>> > Hi,
>> >
>> > several times we had projects where one of the requirements was to >
trigger
>> > some special functionality before sending an email from oxemail class.
>> > Especially if this special functionality is dependent on the type of
>> > email - it is quite cumberesome to solve this, cause in the _sendMail()
>> > function you do not know which type of email has to be sent.
>> >
>> > So I would like to have a property which is filled by the name of the
>> > function which has been called before, like this:
>> >
>> > $_sActMailFunctionCall = "";
>> >
>> > public function sendOrderEmailToOwner( $sOrder, $sSubject = null )
>> > {
>> > $this->_sActMailFunctionCall = "sendOrderEmailToOwner";
>> > ...
>> > }
>> >
>> > Of course you could even build a small sort of factory function which
>> > would be called by the several view classes, doing this job - so you >
would
>> > not have to put a new line of coude into each mail function - like this
>> > for example:
>> >
>> > in class oxEmail:
>> >
>> > public function executeSendMailFunction( $sFunction, $aParams )
>> > {
>> > $this->_sActMailFunctionCall = $sFunction;
>> > $this->$sFunction( $aParams);
>> > }
>> >
>> > in oxOrder::_sendOrderByEmail():
>> >
>> > $oxEmail->executeSendMailFunction( "sendOrderEmailToOwner", $aParams );
>> >
>> > Doing this would give developers a whole bunch of nice possibilities. > For
>> > example you could write a central function to manipulate email subjects
>> > dependent on the type of email. Or you could save the content of > special
>> > email and so on ...
>> > At the moment all this is possible - but you have to overload a lot of
>> > functions for this to detect the type of email.
>> >
>> > Using the factory function would mean that the several send-functions
>> > would not have to be changed appart from the parameters given to them. >
But
>> > even this could be done inside the factory, which then would have to
>> > prepare the params for the single calls.
>> >
>> > The "factory way" in my opinion would be the best one regarding code
>> > layout, but I see that in terms of compatibility to old versions and
>> > modules this could cause some trouble .. - So perhaps as a first step > you
>> > could just add the first mentioned line of could to each function?
>> >
>> > If somebody has got a better idea to solve this - let me know!
>> >
>> > Regards,
>> > Andreas
>> >
>> > -- > anzido GmbH
>> > Kirchhörder Str. 12
>> > 44229 Dortmund
>> > Tel.: 0231 - 60 71 079
>> > Fax.: 0231 - 60 71 081
>> > Mobil:0176 - 8325 1488
>> > Email: [email protected]
>> > Web: http://www.anzido.com ( http://www.anzido.com/ )
>> >
>> > USt-ID: DE257982972
>> > Geschäftsführung: Andreas Ziethen
>> > Amtsgericht Dortmund HRB 20883
>> > _______________________________________________
>> > dev-general mailing list
>> > [email protected]
>> > http://dir.gmane.org/gmane.comp.php.oxid.general
>> >
>> _______________________________________________
>> dev-general mailing list
>> [email protected]
>> http://dir.gmane.org/gmane.comp.php.oxid.general
>
> _______________________________________________
> dev-general mailing list
> [email protected]
> http://dir.gmane.org/gmane.comp.php.oxid.general
>
_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general
_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general