From 282c0bc90f7217ad001f34d7ffa9c4020807969a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 28 Feb 2017 13:27:48 +0100 Subject: [PATCH] method to disable a hook for the current request --- api/src/Hooks.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api/src/Hooks.php b/api/src/Hooks.php index 06d1de1fc3..c006dc0187 100644 --- a/api/src/Hooks.php +++ b/api/src/Hooks.php @@ -203,6 +203,23 @@ class Hooks return isset(self::$locations[$location]) ? array_keys(self::$locations[$location]) : array(); } + /** + * Disable a hook for this request + * + * @param string $hook + * @return boolean true if hook existed, false otherwise + */ + static public function disable($hook) + { + if (!isset(self::$locations)) self::read(); + + $ret = isset(self::$locations[$hook]); + + unset(self::$locations[$hook]); + + return $ret; + } + /** * Read all hooks into self::$locations *