July 29, 2007

About: request handling

Filed under: ZenMagick — DerManoMann @ 11:38 pm

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:

  1. With a few exceptions, all core classes are loaded (require/include). Alternatively, if core.php exists, that is loaded instead
  2. All global ZenMagick variables are instantiated ($zm_xxx)
  3. local.php is loaded
  4. If configured, the ZenMagick error handler is set up as global error handler
  5. Themes get initialized. This happens as a recursive call to zm_resolve_theme(..) 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 l10n and i18n configuration and mappings
  6. Set up some zen-cart fixes
  7. 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
  8. Load enabled plugins and initialize by calling the init() method
  9. 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:

  1. Determine the name of the responsible controller class
  2. Create controller instance (if no specific controller is found, ZMDefaultController will be used)
  3. Check if valid request (this is a bit obsolete and should be reviewed)
  4. Call the controllers process() method;
    This will result in calling either the processGet() or processPost() 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.
  5. If the process() method returned a ZMView instance, call the generate() method on that
  6. Call filterResponse(..) on all ZMPluginHandler instances that are configured
  7. Cleanup session
  8. done!

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.