Custom hooks for plugins

This commit is contained in:
dignajar 2020-05-12 18:24:06 +02:00
parent 5b85f90f72
commit 41b5531fa2
2 changed files with 17 additions and 3 deletions

View File

@ -31,9 +31,13 @@ class Plugin {
// (boolean) Enable or disable default Save and Cancel button on plugin settings
public $formButtons;
// (array) List of custom hooks
public $customHooks;
function __construct()
{
$this->dbFields = array();
$this->customHooks = array();
$reflector = new ReflectionClass(get_class($this));

View File

@ -101,6 +101,16 @@ function buildPlugins()
// If the plugin is installed insert on the hooks
if ($Plugin->installed()) {
// Include custom hooks
if (!empty($Plugin->customHooks)) {
foreach ($Plugin->customHooks as $customHook) {
if (!isset($plugins[$customHook])) {
$plugins[$customHook] = array();
$pluginsEvents[$customHook] = array();
}
}
}
$pluginsInstalled[$pluginClass] = $Plugin;
foreach ($pluginsEvents as $event=>$value) {
if (method_exists($Plugin, $event)) {