[dev] Hooks config change proposal

Michael M Slusarz slusarz at horde.org
Sat Jul 25 18:25:54 UTC 2009


Quoting Jan Schneider <jan at horde.org>:

>> It's going to be a major PITA to maintain hooks (and the  
>> corresponding config options) in every single application.   
>> Although thinking about this a bit more, doing everything in one  
>> hook in Horde is also not optimal since we would be in Horde scope  
>> (not the app scope) at that point.  Any code written there would  
>> need to do manual pushApp()/popApp() calls which is probably asking  
>> too much for an admin-level coder.
>
> We actually don't have to maintain any hooks. We just need to  
> provide examples. And I agree that from an admin's point of view it  
> makes more sense to have a hook per application. Having split out  
> the application hooks from Horde to the corresponding application a  
> while ago definitely helped understanding and finding hooks.

For hooks, what about changing the config file to a class.  So an  
app's config file would look like:

class App_Hooks
{
     // Example Hook
     // static public function hook_name
     // {
     // }
}

Then Horde::callHook() just needs to include the config file and do a  
method_exists check.  This would get rid of the function_exists()  
calls that litter hooks.php, gets rid of the static $_hooksLoaded  
variable in Horde::callHook (we can rely on require_once instead, or  
configure Autoloader to look for *_Hooks classes in the config  
directory), and would also get rid of the need to have a config entry  
to activate the hooks.  IMHO, defining the hook in the hooks.php file  
should be sufficient to activate.

michael

-- 
___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the dev mailing list