Perhaps i'm over thinking the Registry?
Posted: Fri Nov 03, 2006 11:19 am
Question. it's a bigun so pay attention
. second part is a smllun
i have a loader class and it's basically a registry except that it actually instantiates the class within it and keeps the library and it's label within. no big deal. i just added a little bit of functionality to it.
i have all the basica functionality in here. get a library, register a library and all that good stuff. the restry is a very large global in memory (i wanted to keep it smaller but what can i do now
. so that being said if i have a global and i register a class within it:
this is how i get the class and use it's functionality:
well. i've set it and if i'm using an alias for that registry index in the registry array (oh man that's a mouthful) then that means that only that alias has that information. i should create a function within there that actually sets it with the registry correct?
then use it
but this is where the problem is. i might be over thinking it but if i do that then i'm overwriting what was already in there and BAM! it's gone. i can't get to it again and i'm screwed.
well, i have to update what is within that class don't i? and if i do can i do this from the registry class or do i have to add that functionality to each and every class that i have?
also, second question. this class is a registry but it's also an autoloader class. to make it simpler for me. what should i name it? as it stands it's Loader. thoughts on that would be nice
i have a loader class and it's basically a registry except that it actually instantiates the class within it and keeps the library and it's label within. no big deal. i just added a little bit of functionality to it.
i have all the basica functionality in here. get a library, register a library and all that good stuff. the restry is a very large global in memory (i wanted to keep it smaller but what can i do now
Code: Select all
$registry = new BlackBarnRegistry();
$registry->loadDebug('debug.View');Code: Select all
$template = $load->get('View');
$template->set('Body', $BodyText);
$template->fetch('error.tpl');Code: Select all
public function set($object, $label)
{
if (isset($this->library[$label]))
{
$this->library[$label] = $object;
return true;
}
return false;
}Code: Select all
$registry->set($template, 'View');well, i have to update what is within that class don't i? and if i do can i do this from the registry class or do i have to add that functionality to each and every class that i have?
also, second question. this class is a registry but it's also an autoloader class. to make it simpler for me. what should i name it? as it stands it's Loader. thoughts on that would be nice