Hi Ralph,

>> if (false === class_exists('ClassA')) { //dynamically check to see if
>> a local overriding class exists via the autoloader
>>   $class = new DefaultClass();
>> } else {
>>   $class = new ClassA();
>> }
>
> What is an "overriding class"?


In the above 'overriding' is the 'preferred' class to use, else use a
default one (which doesn't have to be of the same namespace).

> By doing that, you can be sure that the stack of autoloaders is exactly as
> you expect it to be.  You can also use the PHP 5.3 only feature of
> spl_autoload_register "prepend flag" to ensure things are in the order you
> expect them to be in:

Even with the prepend flag it doesn't alleviate the problem, because
if 'Class A' is not found in the first registered autoloader, all of
the other (if any) autoloaders are then called - which in the above
example would be unnecessary.

To me the problem is somewhat similar to finding a ZF1 View Helper, it
iterates through until it finds one.

My point, or preference is, is that we should try and encourage only
registering one autoloader handler for the application. I've also
wonder it should be similar to ZF1's plugin priority stack, which may
also then provide the developer more control of the execution stack
(if needed). I realize that in ZF2 this may not be an issue if say
only the Class Map autoloader is the only registered handler.

For example, if the handler could prevent the autloader stack from
automatically continuing onto calling the subsequent registered
handlers because the one for that namespace knows it could not find
and that none of the handlers will either.


Regards,

-- 
Greg

--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to