How do I go about calling a function (method) in one plugin from another plugin.
default.php( of PluginOne)
snippet....
class PluginOne extends Gdn_Plugin {
public function test1($Sender) {
// do something
}
what would be the procedure (syntax) to call test1 from within PluginTwo
default.php (of PluginTwo)
class PluginTwo extends Gdn_Plugin {
public function Testing ($Sender) {
// call to test1 in pluginOne
??? what would be the correct syntax
??????????::test1($Sender);
}
0

Comments
AFAIK, it is not possible unless:
I think the first option would be best (although I doubt there is a reference in $Sender). Otherwise I would extend the first plugin. It would be something along the lines of:
class PluginTwo extends PluginOne { public function test1 ($Sender) { // call to test1 in pluginOne parent::test1($Sender); }thanks @hgtonight
it gives me some ideas. I'll see what $Sender knows. I don't think option 2 is going to work the way I want to do things.
You can call other plugins by using
Gdn::PluginManager().Simplest example:
// Retrieve plugin by class name $PluginInstance = Gdn::PluginManager()->GetPluginInstance('PluginOne'); // Same as above, passing the Sender $PluginInstance = Gdn::PluginManager()->GetPluginInstance('PluginOne', Gdn_PluginManager::ACCESS_CLASSNAME, $Sender); // Retrieve plugin by plugin name (i.e. the one declared in Plugin information array $PluginInstance = Gdn::PluginManager()->GetPluginInstance('NameOfPluginOne', Gdn_PluginManager::ACCESS_PLUGINNAME); // Same as above, passing the Sender $PluginInstance = Gdn::PluginManager()->GetPluginInstance('NameOfPluginOne', Gdn_PluginManager::ACCESS_PLUGINNAME, $Sender);.
@businessdad
perfecto, I learned something new today.
You're welcome.