| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Libteiser - Ojs/ojs2/classes/plugins/ |
Upload File : |
<?php
/**
* @file classes/plugins/HookRegistry.inc.php
*
* Copyright (c) 2003-2009 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class HookRegistry
* @ingroup plugins
*
* @brief Class for linking core functionality with plugins
*/
// $Id: HookRegistry.inc.php,v 1.11.2.1 2009/04/08 19:42:49 asmecher Exp $
class HookRegistry {
/**
* Get the current set of hook registrations.
*/
function &getHooks() {
static $hooks = array();
return $hooks;
}
/**
* Set the hooks table for the given hook name to the supplied array
* of callbacks.
* @param $hookName string Name of hook to set
* @param $hooks array Array of callbacks for this hook
*/
function setHooks($hookName, $hooks) {
$hooks = &HookRegistry::getHooks();
$hooks[$hookName] =& $hooks;
}
/**
* Clear hooks registered against the given name.
* @param $hookName string Name of hook
*/
function clear($hookName) {
$hooks = &HookRegistry::getHooks();
unset($hooks[$hookName]);
return $hooks;
}
/**
* Register a hook against the given hook name.
* @param $hookName string Name of hook to register against
* @param $callback object Callback pseudotype
*/
function register($hookName, $callback) {
$hooks = &HookRegistry::getHooks();
if (!isset($hooks[$hookName])) {
$hooks[$hookName] = array();
}
$hooks[$hookName][] =& $callback;
}
/**
* Call each callback registered against $hookName in sequence.
* The first callback that returns a value that evaluates to true
* will interrupt processing and this function will return its return
* value; otherwise, all callbacks will be called in sequence and the
* return value of this call will be the value returned by the last
* callback.
* @param $hookName string The name of the hook to register against
* @param $args string Hooks are called with this as the second param
* @return mixed
*/
function call($hookName, $args = null) {
$hooks = &HookRegistry::getHooks();
if (!isset($hooks[$hookName])) {
return false;
}
foreach ($hooks[$hookName] as $hook) {
if ($result = call_user_func($hook, $hookName, $args)) {
break;
}
}
return $result;
}
}
?>