[Solar-talk] Proposal: Remove namespace to Solar::loadClass()/factory()
Travis Swicegood
development at domain51.com
Tue Nov 7 09:43:39 PST 2006
Hi Rodrigo,
Just a quick - out of order response:
> 3.Do the same in Solar::factory():
If Solar::loadClass() is changed, Solar::factory() does not need to be
changed as it relies on Solar::loadClass().
Rodrigo Moraes wrote:
> 1. Set an array in Solar config mapping Solar classes to the class you
> want to use (by default, empty):
>
> $config['Solar']['classes'] = array(
> 'Solar_Sql' => 'Domain51_Sql',
> );
>
> 2. Replace $class in Solar::loadClass(), if it is mapped to another one:
>
> public static function loadClass($class)
> {
> if(isset($this->config['classes'][$class])) {
> $class = $this->config['classes'][$class];
> }
> ...
>
> ... snip ...
>
> Maybe I have missed something, but if not maybe this would be simple
> and nice enough?
The issue here again is that you have to configure that you want to
change objects out. What I am going for with the namespaces idea is
that it makes Solar completely aware of all of the files in your Vendor
namespace the way Solar_Controller_Front is aware of all of your
Vendor_App files. It's basically applying a very similar logic from
S_C_Front to all requests to Solar::loadClass().
One thing you have to be careful with when you introduce new
configuration options is how easily they can be managed. If I wanted to
write replacements for all of the Solar classes, my config file would
become huge by maintaining a list of every class I want to override.
-Travis
More information about the solar-talk
mailing list