diff options
Diffstat (limited to 'application/plugin/PluginManager.php')
-rw-r--r-- | application/plugin/PluginManager.php | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/application/plugin/PluginManager.php b/application/plugin/PluginManager.php index f7b24a8e..da66dea3 100644 --- a/application/plugin/PluginManager.php +++ b/application/plugin/PluginManager.php | |||
@@ -16,7 +16,7 @@ class PluginManager | |||
16 | * | 16 | * |
17 | * @var array $authorizedPlugins | 17 | * @var array $authorizedPlugins |
18 | */ | 18 | */ |
19 | private $authorizedPlugins; | 19 | private $authorizedPlugins = []; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * List of loaded plugins. | 22 | * List of loaded plugins. |
@@ -100,21 +100,36 @@ class PluginManager | |||
100 | */ | 100 | */ |
101 | public function executeHooks($hook, &$data, $params = array()) | 101 | public function executeHooks($hook, &$data, $params = array()) |
102 | { | 102 | { |
103 | if (!empty($params['target'])) { | 103 | $metadataParameters = [ |
104 | $data['_PAGE_'] = $params['target']; | 104 | 'target' => '_PAGE_', |
105 | } | 105 | 'loggedin' => '_LOGGEDIN_', |
106 | 106 | 'basePath' => '_BASE_PATH_', | |
107 | if (isset($params['loggedin'])) { | 107 | 'rootPath' => '_ROOT_PATH_', |
108 | $data['_LOGGEDIN_'] = $params['loggedin']; | 108 | 'bookmarkService' => '_BOOKMARK_SERVICE_', |
109 | ]; | ||
110 | |||
111 | foreach ($metadataParameters as $parameter => $metaKey) { | ||
112 | if (array_key_exists($parameter, $params)) { | ||
113 | $data[$metaKey] = $params[$parameter]; | ||
114 | } | ||
109 | } | 115 | } |
110 | 116 | ||
111 | foreach ($this->loadedPlugins as $plugin) { | 117 | foreach ($this->loadedPlugins as $plugin) { |
112 | $hookFunction = $this->buildHookName($hook, $plugin); | 118 | $hookFunction = $this->buildHookName($hook, $plugin); |
113 | 119 | ||
114 | if (function_exists($hookFunction)) { | 120 | if (function_exists($hookFunction)) { |
115 | $data = call_user_func($hookFunction, $data, $this->conf); | 121 | try { |
122 | $data = call_user_func($hookFunction, $data, $this->conf); | ||
123 | } catch (\Throwable $e) { | ||
124 | $error = $plugin . t(' [plugin incompatibility]: ') . $e->getMessage(); | ||
125 | $this->errors = array_unique(array_merge($this->errors, [$error])); | ||
126 | } | ||
116 | } | 127 | } |
117 | } | 128 | } |
129 | |||
130 | foreach ($metadataParameters as $metaKey) { | ||
131 | unset($data[$metaKey]); | ||
132 | } | ||
118 | } | 133 | } |
119 | 134 | ||
120 | /** | 135 | /** |