News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen's Blog:
Hooks in Action Helpers
November 05, 2008 @ 09:34:40

Rob Allen has posted this look at using hooks inside of action helpers (a follow-up from his previous article on action helpers):

Hooks are a feature of action helpers that allow you to automatically run code at certain points in the dispatch cycle. Specially, there are two hook functions available for action helpers: preDispatch and postDispatch. These allow you to ensure that some functionality is always run for each request.

He creates a simple action helper that grabs a random quote from an array and drops it into a property of the helper. By defining a preDispatch method inside of the helper, the HelperBroker knows to pull the method in an execute it immediate before the rest of the actions are executed. A calls to addHelper with the hooks defined is all it takes to glue it together with the execution.

0 comments voice your opinion now!
hook action helper random quote tutorial addhook helperbroker zendframework


blog comments powered by Disqus

Similar Posts

UncleCode.com: Install PHPUnit Manually without Pear for a Single Project

Padraic Brady's Blog: Optimise Your Zend_Feed Aggregators With HTTP Conditional GET Support

Zend Developer Zone: Results of April's ZF Bug Hunt Days

Developer Tutorials Blog: Building Web 2.0 Tag Clouds in PHP

Benjamin Eberlei: Composer and Azure Websites Git Deployment


Community Events





Don't see your event here?
Let us know!


podcast introduction interview list laravel opinion language series configure code release refactor wordpress framework testing threedevsandamaybe community install developer unittest

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework