Update Code and shortend it
the new code allows mutliple plugins using the custom hook instead of overwriting the existing array
This commit is contained in:
parent
4f1c27255c
commit
77b1c119e9
@ -99,25 +99,23 @@ 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()) {
|
||||||
|
|
||||||
|
// If the plugin contains the function "registerHooks" returning a String array,
|
||||||
|
//it will called and if those hooks are not existing they will added
|
||||||
|
if(method_exists($Plugin, "registerHooks")) {
|
||||||
|
foreach (call_user_func("{$Plugin->className()}::registerHooks") as $customEvent) {
|
||||||
|
if(!isset($plugins[$customEvent])){
|
||||||
|
$plugins[$customEvent] = array();
|
||||||
|
$pluginsEvents[$customEvent] = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pluginsEvents as $event=>$value) {
|
foreach ($pluginsEvents as $event=>$value) {
|
||||||
if (method_exists($Plugin, $event)) {
|
if (method_exists($Plugin, $event)) {
|
||||||
array_push($plugins[$event], $Plugin);
|
array_push($plugins[$event], $Plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* THIS PART IS FOR CUSTOM HOOKS */
|
|
||||||
if(method_exists($Plugin, "registerHooks"))
|
|
||||||
{
|
|
||||||
foreach (call_user_func("{$Plugin->className()}::registerHooks") as $customEvent)
|
|
||||||
{
|
|
||||||
if (method_exists($Plugin, $customEvent))
|
|
||||||
{
|
|
||||||
$plugins[$customEvent] = array();
|
|
||||||
array_push($plugins[$customEvent], $Plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* THIS PART IS FOR CUSTOM HOOKS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uasort($plugins['siteSidebar'], function ($a, $b) {
|
uasort($plugins['siteSidebar'], function ($a, $b) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user