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?
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_Email
class in/plugins/MyPlugin/library/class.email.php
and the autoloader brought it into scope as necessary.Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
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?
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
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.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
example?
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Incoming...
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
So... I mixed up.
You can alias classes that are accessed via the
Gdn
class 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
Gdn
class. This is because the act of extending the class brings it into scope.Sorry for the error on my part.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
All you have to do is predefine the class then it will skip the autoloader
http://vanillaforums.org/discussion/comment/206846/#Comment_206846
grep is your friend.
Right. But you don't even have to do that since plugin folders have priority in the autoloader.
I placed the my custom
Gdn_Email
class in/plugins/MyPlugin/library/class.email.php
and the autoloader brought it into scope as necessary.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
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.