Get Request Flow

get request flow

index.php

All transactions initially execute index.php as a result of redirection which occurs in the .htaccess file. This is where you would specify where the framework and application reside.

It calls the bootstrap.php module in the application and then calls the frontController, or AjaxController based on the url.

ajax in the first node means it will be treated as an ajax transaction.

bootstrap.php

This module resides in the application and does some initialization. You may add application specific logic to this module if you like.

sys_front_controller.php

This module resides in the framework and processes Get or Post transctions. It calls the sys_request class to parse the url, and look up the command in the commands.xml file. The important thing to note here is that commands.xml, which resides in the configuration directory maps urls to action classes. The front controller then calls the action class, which in the case of a get is known in the framework as a navigation action.

Navigation Action

The navigtation action resides in the /modules/[module_name]/controllers/navigation_action directory of the application with a name like [module]_nav_[descriptive_name].php and has a class of that name inside.

The job of the Navigation Action is to load any data that the view is going to need and display the template. Navigation is done inside a loop, so if the action determines that another module is better suited to taking over the processing, it can bypass the display of the template and instead return a url for a different Navigation Action.

This would start the process over in the front controller. A classic example of this is to return an error, and let the error module take care of displaying an appropriate screen to the user.

Template

Hardhat uses Smarty templates for this. The Navigation Action passes data to the template by assigning it to the Smarty instance and then calling displayTemplate as follows:

$smarty->assign("user", $user);
$smarty->display($template);

The template can then refer to this data as:

  First Name: {$user->getFirstName()}<br />
  Last Name: {$user->getLastName()}

You can read about why I like smarty here.