*/
public function executeHooks($hook, &$data, $params = array())
{
- if (!empty($params['target'])) {
- $data['_PAGE_'] = $params['target'];
- }
-
- if (isset($params['loggedin'])) {
- $data['_LOGGEDIN_'] = $params['loggedin'];
- }
-
- if (isset($params['basePath'])) {
- $data['_BASE_PATH_'] = $params['basePath'];
+ $metadataParameters = [
+ 'target' => '_PAGE_',
+ 'loggedin' => '_LOGGEDIN_',
+ 'basePath' => '_BASE_PATH_',
+ 'bookmarkService' => '_BOOKMARK_SERVICE_',
+ ];
+
+ foreach ($metadataParameters as $parameter => $metaKey) {
+ if (array_key_exists($parameter, $params)) {
+ $data[$metaKey] = $params[$parameter];
+ }
}
foreach ($this->loadedPlugins as $plugin) {
$hookFunction = $this->buildHookName($hook, $plugin);
if (function_exists($hookFunction)) {
- $data = call_user_func($hookFunction, $data, $this->conf);
+ try {
+ $data = call_user_func($hookFunction, $data, $this->conf);
+ } catch (\Throwable $e) {
+ $error = $plugin . t(' [plugin incompatibility]: ') . $e->getMessage();
+ $this->errors = array_unique(array_merge($this->errors, [$error]));
+ }
}
}
+
+ foreach ($metadataParameters as $metaKey) {
+ unset($data[$metaKey]);
+ }
}
/**