Custom hooks for plugins
This commit is contained in:
parent
5b85f90f72
commit
41b5531fa2
|
@ -31,9 +31,13 @@ class Plugin {
|
||||||
// (boolean) Enable or disable default Save and Cancel button on plugin settings
|
// (boolean) Enable or disable default Save and Cancel button on plugin settings
|
||||||
public $formButtons;
|
public $formButtons;
|
||||||
|
|
||||||
|
// (array) List of custom hooks
|
||||||
|
public $customHooks;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->dbFields = array();
|
$this->dbFields = array();
|
||||||
|
$this->customHooks = array();
|
||||||
|
|
||||||
$reflector = new ReflectionClass(get_class($this));
|
$reflector = new ReflectionClass(get_class($this));
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,16 @@ function buildPlugins()
|
||||||
|
|
||||||
// If the plugin is installed insert on the hooks
|
// If the plugin is installed insert on the hooks
|
||||||
if ($Plugin->installed()) {
|
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;
|
$pluginsInstalled[$pluginClass] = $Plugin;
|
||||||
foreach ($pluginsEvents as $event=>$value) {
|
foreach ($pluginsEvents as $event=>$value) {
|
||||||
if (method_exists($Plugin, $event)) {
|
if (method_exists($Plugin, $event)) {
|
||||||
|
|
Loading…
Reference in New Issue