Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Custom Hooks For Apps

edited September 2014 in Miscellaneous

I've been scrubbing through the source and I can't seem to find a way of managing hooks for custom apps outside of manually editing the root config, which isn't distributed with individual apps.

The simplest solution I've been able to come up with so far is adding this to the Controller class:

    public function apphook ($app , $type, $data = array ()) {
        $hooks = empty(Appconf::get($app)['Hooks'][$type]) ? array() : Appconf::get($app)['Hooks'][$type];
        if (empty($hooks) {
            return false;
        $out = '';
        foreach ($hooks as $handler) {
            $out .= $this->run ($handler, $data);
        return $out;

Haven't been able to test this much, so it might be a bit off...


  • I think you're right, hooks need to be managed in a more general way, since editing the main config file to change them doesn't lend itself well to managing hooks between a variety of custom apps, or making them user-configurable.

    I just made a commit so the Controller::hook() method now autoloads them from each app's conf/config.php:

    This is similar to your idea, but keeps the same method and happens behind the scenes. Let me know what you think!

  • Looks good. I'll do some tests when I get some free time.

Sign In or Register to comment.