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);
            }
                I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
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); }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.
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.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
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);My shop | About Me
.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@businessdad
perfecto, I learned something new today.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
You're welcome.
My shop | About Me