[Solar-talk] Proposal: Remove namespace to Solar::loadClass()/factory()

Matt M. goodieboy at gmail.com
Tue Nov 7 09:29:46 PST 2006


Just so I understand... something like this? Just add the namespaces array
to Solar config.

public function loadClass($class, $concrete=false)
    {
        if( ! $concrete )
        {
            $config = Solar::config('Solar');
            $namespaces = $config['namespaces'];
            if( ! in_array('Solar', $namespaces) )
            {
                $namespaces[] = 'Solar';
            }

            foreach($namespaces as $namespace)
            {

                $namespaced_class = $namespace . '_' . $class;

                if( class_exists($namespaced_class) )
                {
                    return $namespaced_class;
                }

                $class_file = str_replace('_', DIRECTORY_SEPARATOR,
$namespace) . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR,
$class) . '.php';
                if( file_exists($class_file) )
                {
                    require_once $class_file;
                    return $namespaced_class;
                }
            }
        }
        return $class;
    }

On 11/7/06, Rodrigo Moraes <rodrigo.moraes at gmail.com> wrote:
>
> On 11/7/06, Travis Swicegood wrote:
> > By specifying "true" as the second parameter, you could override the
> > namespace code.  This would be necessary for sub-classes that need to
> > insure the specific super-class they expect is loaded.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20061107/494c59ef/attachment.htm 


More information about the solar-talk mailing list