You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 12, 2023. It is now read-only.
If your plugin has a normal and an autoloaded version, you may need to define some functions only once and use them in both versions (ie: a datalayer access).
To achieve this goal, you can add the _util.php file to your plugin root folder.
This file must contain a class that extends the EvnPluginUtil abstract class setting the name as your plugin name (all lowercase!) and adding _util after it.
In this class you can define any function you need. This class can access the caller object using its caller property. So any plugin can use a util function, simply calling it this way:
You can define any kind of functions inside the util class. The functions must be defined as public.
Example from the helloworld plugin.
class helloworld_util extends EvnPluginUtil
{
public function common_function()
{
return 'This string has been generated by a common function, called by "'.$this->caller->get_name().'" plugin: it\'s defined once and can be used from the normal and the autoload versions of the plugin.';
}
}
The function in our example is called, inside the activate() normal plugin method, with: