X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FHook.php;h=d7b1f737a0289ad0e30c837ffb33e44fe4acdae7;hb=56a77f5275ba8566a37d690ade0e929c88b828e2;hp=8fdadd666a9c769da520feff285f8cc32d21c2d6;hpb=2ec3a97393959e42d450e074271d2d622d25701f;p=friendica.git diff --git a/src/Core/Hook.php b/src/Core/Hook.php index 8fdadd666a..d7b1f737a0 100644 --- a/src/Core/Hook.php +++ b/src/Core/Hook.php @@ -99,9 +99,7 @@ class Hook return true; } - $result = DBA::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]); - - return $result; + return self::insert(['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]); } /** @@ -119,10 +117,10 @@ class Hook // This here is only needed for fixing a problem that existed on the develop branch $condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; - DBA::delete('hook', $condition); + self::delete($condition); $condition = ['hook' => $hook, 'file' => $relative_file, 'function' => $function]; - $result = DBA::delete('hook', $condition); + $result = self::delete($condition); return $result; } @@ -220,7 +218,7 @@ class Hook } else { // remove orphan hooks $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]]; - DBA::delete('hook', $condition, ['cascade' => false]); + self::delete($condition, ['cascade' => false]); } } @@ -245,4 +243,45 @@ class Hook return false; } + + /** + * Deletes one or more hook records + * + * We have to clear the cached routerDispatchData because addons can provide routes + * + * @param array $condition + * @param array $options + * @return bool + * @throws \Exception + */ + public static function delete(array $condition, array $options = []) + { + $result = DBA::delete('hook', $condition, $options); + + if ($result) { + DI::cache()->delete('routerDispatchData'); + } + + return $result; + } + + /** + * Inserts a hook record + * + * We have to clear the cached routerDispatchData because addons can provide routes + * + * @param array $condition + * @return bool + * @throws \Exception + */ + private static function insert(array $condition) + { + $result = DBA::insert('hook', $condition); + + if ($result) { + DI::cache()->delete('routerDispatchData'); + } + + return $result; + } }