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