Jump to content

Custom class in plugin?


Recommended Posts

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...