Twitter Feed

Xataface Maillist

Sign up to receive the Xataface news letter with weekly updates and development tips.

Found 1 of 139 records in table Wiki
Now Showing 1 of 1

Current Record: beforeHandleRequest

beforeHandleRequest Application Delegate Class Method


Return to Application Delegate Class


The beforeHandleRequest method is a very useful hook that can be implemented in an Application Delegate Class to perform some processing before every request.

This hook is called after user authentication is taken care of, but before control has been passed to the specific action. This means that it is possible to do things such as change the current action or adjust query parameters depending on various factors.

Example Uses

  • To require users to fill agree to license terms before they can visit particular parts of the application.
  • To implement custom logging functionality to record user actions
  • To change the default action for some or all tables.
  • To automatically create user accounts in some cases.
  • To change query parameters (e.g. default sorting etc...).


Example 1: Changing the default action for a particular table

class conf_ApplicationDelegate {
    function beforeHandleRequest(){
        $app = Dataface_Application::getInstance();
        $query =& $app->getQuery();
            // Make sure you assign by reference (i.e. =& )
            // for this if you want to make changes to the query
        if ( $query['-table'] == 'dashboard' and @$app->_conf['using_default_action'] ){
            $query['-action'] = 'my_default_action';

In the above example, we make use of the Application configuration variable using_default_action? to find out if the request is using the default action. This flag is set by Xataface if the user hasn't explicitly declared the action in the URL (i.e. -action has not explicitly been set).

See Also

blog comments powered by Disqus
Powered by Xataface
(c) 2005-2023 All rights reserved