Override method Gdn_Email->Send();
I would like to override the method: Gdn_Email->Send();
I can not with (in a extension): public function Gdn_Email_Send_Override(&$Sender) {}
Yet I have read the documentation.
Do you have any idea?
0
Best Answer
-
hgtonight
MVP
@x00 said:
All you have to do is predefine the class then it will skip the autoloaderhttp://vanillaforums.org/discussion/comment/206846/#Comment_206846
Right. But you don't even have to do that since plugin folders have priority in the autoloader.
hgtonight said:
You can also override classes by placing them in the appropriate folder of your plugin.I placed the my custom
Gdn_Emailclass in/plugins/MyPlugin/library/class.email.phpand the autoloader brought it into scope as necessary.7
Answers
latest info on magic events.
http://docs.vanillaforums.com/developers/plugins/
maybe you can get by using FireEvent -
https://github.com/vanilla/vanilla/blob/2.1/library/core/class.email.php#L247
what is it that you actually want to change?
Thank you for your reply.
I tried using the SendMail event but it does not work because the variable $EventName is empty (tested when creating a new account).
My goal is to be able to send emails site + forum with the same function. (html, header + footer).
I will look to replace the whole class.
Extend the class, rewrite the method, and register your custom class as an alias in the autoloader.
example?
Incoming...
So... I mixed up.
You can alias classes that are accessed via the
Gdnclass such asGdn::Session()using the following code:You can also override classes by placing them in the appropriate folder of your plugin. Alternatively, you can register a different mapping to the autoloader:
You cannot, however extend a class and then override that same class, unless it is accessed through the
Gdnclass. This is because the act of extending the class brings it into scope.Sorry for the error on my part.
All you have to do is predefine the class then it will skip the autoloader
http://vanillaforums.org/discussion/comment/206846/#Comment_206846
Right. But you don't even have to do that since plugin folders have priority in the autoloader.
I placed the my custom
Gdn_Emailclass in/plugins/MyPlugin/library/class.email.phpand the autoloader brought it into scope as necessary.Thank you very much for your answers !!
I confirm @hgtonight: if the class is placed in the library folder plugin, it is automatically loaded.
Too bad we can not just override some methods as with Prestashop.