2012年3月8日星期四

Rob Allen's Blog: Module specific bootstrapping in ZF2


Rob Allen has a new post to his blog today looking at bootstrapping specific modules in a Zend Framework 2-based application without having to do the entire set.



Following on from the discussion on modules, we can hook into the event system to do module specific bootstrapping. By this, I mean, if you have some code that you want to run only if the action to be called is within this module, you can hook into the Application's dispatch event to achieve this.


He starts with an example of a basic module (Simple/Module.php) and shows how to define an "onBootstrap" method that calls the "onDispatch" method (when hooked to the event manager) to do some module-specific bootstrap operations. The RouteMatch feature is used to ensure that you're in the right controller/namespace combo to use the module.

没有评论:

发表评论