ZF-101: Zend_View_Abstract::_loadClass() doesn't work with classes on the include path (TRAC#99)

Description

http://framework.zend.com/developer/ticket/99

Zend_View_Abstract::_loadClass() calls is_readable() to find out if the particular file exists on the path.

This causes problems when you want to have a set of common view helpers for multiple projects. In my case, I use a directory called Akrabat/View/Helper as part of a tree that mirrors the ZF tree for consistency.)

My preference would be to change


    if (is_readable($dir . $file)) {

to


    if (Zend::isReadable($dir . $file)) {

to solve this problem.

Suggested patch attached.

Comments

05/28/06 16:18:19: Modified by rob.nospam@akrabat.com

* attachment Zend_View_Abstract.patch added.

Suggested patch v1

Rather than make the class dependant on Zend.php how about changing...

 
if (is_readable($dir . $file)) {
    include $dir . $file;

...to...

 
if (include $dir . $file) {

...which would achieve much the same result

Forget my suggestion...

 
if (include $dir . $file) {

...as this produces warnings as each _path stack is looped over

Mind looking at this for 0.2.0?

One way is explode the path and then loop through it doing a Zend::isReadable() for each path with the requested file, that is somewhat slow in my eyes, but it's the only solution I see for making this work.

Fixed in 1428

Further analysis shows that the original behaviour was intentional. addScriptPath() can be used at any point to add additional view script paths to the view object. The reporter need only have done the following:


$view->addScriptPath('/path/to/common/view/scripts');

Behaviour was intentional, and a way to do as the reporter desired already existed in the code.