DreamOn Posted April 22, 2020 Share Posted April 22, 2020 Hello, I'm creating a plugin for IPS with many hooks. I want all my plugin hooks can access to a PHP function but I don't know where to define this function, I would like to define a custom class in the plugin but how? For the moment, I have created a hook of \IPS\Settings with my PHP function: class hook13 extends _HOOK_CLASS_ { public function myFunction() { ... myFunction() is reachable by all plugin hooks via \IPS\Settings::i()->myFunction() but it's not clean, the PHP function is reachable by all others plugins and could create conflict. Do you know how can I have a PHP function reachable by all hooks in a plugin? Thanks! Link to comment Share on other sites More sharing options...
bfarber Posted April 22, 2020 Share Posted April 22, 2020 The method you are describing is fine. Plugins can't really add their own classes cleanly like an application can so unless you want to build an application instead of a plugin, just add your methods to an existing class. DreamOn 1 Link to comment Share on other sites More sharing options...
DreamOn Posted April 22, 2020 Author Share Posted April 22, 2020 5 hours ago, bfarber said: The method you are describing is fine. Plugins can't really add their own classes cleanly like an application can so unless you want to build an application instead of a plugin, just add your methods to an existing class. Thanks @bfarber. So I have to define function with unique name to prevent conflict with others plugins? Link to comment Share on other sites More sharing options...
bfarber Posted April 22, 2020 Share Posted April 22, 2020 That would be a good idea yes Link to comment Share on other sites More sharing options...
Recommended Posts