Back onto my original thought process, I have implemented what I consider to be at least a partial "front controller". The class itself is called Page, and just handles the creation of the page, including the template (the templating itself is handled by a template class, soon to be abstracted by an interface [hopefully], including parsing through it), adding controls (dynamic stuff that the template won't be aware of, thus lightening the load somewhat of the template engine), dynamically loading necessary classes, and other maybe like 2 other things. I've got a few design questions that I've got to look into, including the page configuration being dynamic (not sure if I want to have a single sessioned config and be able to change it when I need to, or if I should load the config on each page to allow for different tasks to use different configs).
What it looks like so far, however is: (not all the code, only config portion)
As you can see my dilemma, is I'm not sure if I want to pass it the config file itself, or just pass it a sessioned config (Singleton!! I understand that much at least). The way it is now has a heavier overhead because of the processing time of loading the config on every single page, but has a more modularized feel that each page in itself can be encapsulated alone.
function LoadConfig($config_file)
{
$this->my_config = $config_file;
$contents = file_get_contents($config_file);
preg_match_all("/config\['([a-zA-Z_]*?)'\]\['([a-zA-Z_]*?)'\] = \"(.*?)\";/", $contents, $cfg_values);
for($i=0; $i$this->my_config_values[$cfg_values[1][$i]][$cfg_values[2][$i]] = $cfg_values[3][$i];
}
Once I get some time to work on this from home, I'll be doing some testing of execution times to see if there's a substantial load time optimization that I'll be in for, or if I can let this one slip by as a "necessary evil", so to speak.
Until next time, $this->post->end();
No comments:
Post a Comment