-- Greg <
[hidden email]> wrote
(on Sunday, 05 September 2010, 04:19 PM -0500):
> I was looking at the Zend_Loader loadClass method and noticed that it
> always throw an exception if it could not load the desired class. Can
> this be optional? Sometimes it might be OK that the class does not
> exist even when trying to load it via the autoloader, eg:
Please look at the implementations in the proposal; none of them utilize
Zend_Loader::loadClass(), and none of them throw exceptions.
Within ZF1's autoloader, we wrap the loadClass() method in a try/catch
block, which allows you to drop to another autoloader if it is unable to
locate the class.
At this point, I'm considering removing Zend_Loader from ZF2 -- with
autoloading as the default, loadClass() really isn't all that necessary,
and most of the other methods present in the class are superceded by
functionality native in PHP 5.3.
> if (class_exists('Custom_Override_Class')) {
> $obj = new Custom_Override_Class();
> } else {
> $obj = new Default_Class();
> }
>
> $obj->doSomething();
--
Matthew Weier O'Phinney
Project Lead |
[hidden email]
Zend Framework |
http://framework.zend.com/PGP key:
http://framework.zend.com/zf-matthew-pgp-key.asc