*/
namespace Friendica\Core;
-use Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Database\dba;
use Friendica\Database\DBM;
-use Friendica\Core\Worker;
-
-use dba;
require_once 'include/dba.php';
if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
foreach ($a->hooks[$name] as $hook) {
- Worker::add($priority, 'ForkHook', $name, json_encode($hook), json_encode($data));
+ Worker::add($priority, 'ForkHook', $name, $hook, $data);
}
}
}
/**
* @brief Calls a single hook.
*
- * @param string $name of the hook to call
- * @param array $hook Hook data
- * @param string|array &$data to transmit to the callback handler
+ * @param App $a
+ * @param string $name of the hook to call
+ * @param array $hook Hook data
+ * @param string|array &$data to transmit to the callback handler
*/
- public static function callSingleHook($a, $name, $hook, &$data = null)
+ public static function callSingleHook(App $a, $name, $hook, &$data = null)
{
// Don't run a theme's hook if the user isn't using the theme
- if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false) {
+ if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . $a->getCurrentTheme()) === false) {
return;
}
} else {
// remove orphan hooks
$condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
- dba::delete('hook', $condition);
+ dba::delete('hook', $condition, ['cascade' => false]);
}
}