[dev] Hooks config change proposal

Jan Schneider jan at horde.org
Sun Jul 26 10:15:55 UTC 2009


Zitat von Michael M Slusarz <slusarz at horde.org>:

> 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.

That sounds like a great simplification.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digitale PGP-Unterschrift
URL: <http://lists.horde.org/archives/dev/attachments/20090726/34d387a1/attachment.bin>


More information about the dev mailing list