CommonHooks

Filepath: phork/php/hooks/CommonHooks.class.php

The CommonHooks class contains a collection of hooks available to all the application. It's called from the bootstrap.

The verifyToken() hook is used in conjunction with the Token utility to verify form posts and displays a fatal error page if the post doesn't verify.

The trackHistory() hook is used to track the last page(s) that the user visited. Certain file extensions such as .css, .js, .xml and json can be excluded. It's useful when redirecting a user back to a previous page.


Example (from the bootstrap)

//the the hooks to verify the form posts and track URL history
if (AppLoader::includeHooks('CommonHooks')) {
    $objCommonHooks = new CommonHooks();
    $objBootstrap->registerPreRunHook(array($objCommonHooks, 'verifyToken'));
    $objBootstrap->registerPostRunHook(array($objCommonHooks, 'trackHistory'), array(5, array('css', 'js', 'xml', 'json', 'jsonp')));
}