Object Loading Mechanism

All systematicly implemented objects in the Framework can be loaded with just one function call. For example:

$tpl = &loadObject('ctl.tpl');

This function is defined in file ./system/lib/ctl/ctlObjectLoader-php4.flib.php.

What happens when calling the function is this:

  1. If an object with the same object full name is found in global array $modules, it is returned at once.
  2. If no object yet exists with the same object full name:
    1. The function searches for loading config for the object in global $modconfig variable (e.g. $modconfig['ctl.tpl']['load'] ).
    2. The function also searches if there is a global module loading config (e.g. $modconfig['ctl']['load']).
    3. If the loading config is not found it is assumed one of the following:
      • there exists a global function for the module called modulename_loader() that is defined in file ./system/modules/modulename/modulename_loader.php
      • there exists a class `Objectname` for the object, defined in: ./system/modules/modulename/Objectname.class.php
      • there exists a class `Modulename` for the module, defined in: ./system/modules/modulename/modulename.class.php
    4. If the loading config was guessed by the system it is filled into global $modconfig array. Also the system assigns $config array values with corresponding names to $modconfig['mod.obj']['config'] variable.
    5. When the class/function file is found. It is called and an object is created and returned.

All _loader() functions and object classes should take two parameters:

  1. $obj_fullname string.
  2. $config array.