About: request handling
It’s about time to give a rough outline of what happens when ZenMagick processes a request. This is assuming a normal GET request, even though POST is virtually the same - the only difference being that the controller will call processPost() rather than processGet().
The first part is the initialization of ZenMagick. Pretty much of of that is done in init.php:
- With a few exceptions, all core classes are loaded (require/include). Alternatively, if
core.phpexists, that is loaded instead - All global ZenMagick variables are instantiated (
$zm_xxx) local.phpis loaded- If configured, the ZenMagick error handler is set up as global error handler
- Themes get initialized. This happens as a recursive call to
until no further theme switch is detected and the default theme is loaded (if theme inheritance is active):- Instantiate theme info class
- Load theme classes
- Load theme’s
local.php(if found) - Load remaining static code
- Load the theme’s
l10nandi18nconfiguration and mappings
- Set up some zen-cart fixes
- If caching is active, this is the time to check for a cache hit for the current request;
If found, return cached contents and cleanup - Load enabled plugins and initialize by calling the
init()method - Fire event
ZM_EVENT_INIT_DONE
This is pretty much the bit that gets done for each request, even with ZenMagick themes disabled (some of the code is conditional, though).
Calling the controller and theme specific view happens later on in store.php:
- Determine the name of the responsible controller class
- Create controller instance (if no specific controller is found,
ZMDefaultControllerwill be used) - Check if valid request (this is a bit obsolete and should be reviewed)
- Call the controllers
process()method;
This will result in calling either theprocessGet()orprocessPost()method. Currently, only a number of controller support POST request handling. If not, the original zen-cart code will be executed as part of the request handling. - If the
process()method returned aZMViewinstance, call thegenerate()method on that - Call
filterResponse(..)on allZMPluginHandlerinstances that are configured - Cleanup session
- done!
