Api plugin that can be used by other plugins

General discussion about MantisBT Plugins

Moderators: Developer, Contributor

Post Reply
Estrobeda
Posts: 1
Joined: 20 Sep 2021, 01:08

Api plugin that can be used by other plugins

Post by Estrobeda »

Hello, I want to make a plugin that basically works like a RestAPI library that other plugins I want to make can use by simply requiring the RestAPI plugin when installing. (This can be done with $this->requires = array('MantisCore' => 'x.xx.x', 'PluginName' => 'x.xx.x'); in the register function.)

However, I want the config to be accessable to the api class.

So the plugin structure is basically

PluginName
-> PluginName.php
-> Pages
-> config_page.php
-> config_page_inc.php
-> Api
-> PluginNameClass.php
etc

So when you're using the api, you instantiate a new instance of PluginNameClass.php.
The issue with this is that api keys and other secrets are set in config_page_inc.php and are accessible through plugin_config_get().
But since another plugin instantiated PluginNameClass.php, those settings are unreachable.

Do someone know a way that allows you to configure the secrets in config_page_inc.php but are accessible to PluginNameClass.php regardless of where it's instantiated and still be unacessable for other plugins? for example setting the secrets in a private parameter in the class.

Or is it hardcoding I have to do....
Post Reply