September 5, 2007

new events

Tags:
Filed under: ZenMagick — DerManoMann @ 3:45 am

I’ve added a few events that will get fired during ZenMagick request processing.

  • ZM_EVENT_DISPATCH_START / ZM_EVENT_DISPATCH_DONE
    Fired before zm_dispatch() is called and after it ended.
  • ZM_EVENT_VIEW_START / ZM_EVENT_VIEW_DONE
    Fired before /after the views generate() method is called. A reference of the view instance is added to the parameters map using the key ‘view‘. (see example below)
  • ZM_EVENT_CONTROLLER_PROCESS_START
    Called by the controllers process() method (but only after authorization has been verified). The controller itself is passed as event source.

In the cases where no real event source is available, the current $zm_runtime instance is used as event source, as null can’t be passed by reference.

Examples of how to meddle with request processing…

To change the view displayed add something like this to a custom event observer class:


// change displayed view
function onZMViewStart($args) {
$view =& $args['view'];
$view->setName(’login’);
}

// add global variable to controller; $foo will be available in the view
function onZMControllerProcessStart($args) {
$controller =& $args['source'];
$controller->exportGlobal(’foo’, $this);
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment