Hi there,

I've been toying around with the new bootstapping mechanism and autoload
capabilities in ZF 1.8. To add the icing on the cake, I'm also using PHP
5.3's new lambda functions.

This combination does not yet work for me, though.

Here's an example from my Bootstrap class:

$loader = Zend_Loader_Autoloader::getInstance();

$loader->pushAutoloader(function($class) use ($fileList) {
    error_log("Loading $class with fileList: " . count($fileList));
    if (!empty($fileList[$class])) {
        require_once $fileList[$class];
    }
}, 'phpillow');

$loader->pushAutoloader(function($class) {
    error_log("Loading $class");
    include APPLICATION_PATH . '/models/' . $class . '.php';
}, 'Model');

Now, when I try to invoke a class "ModelFooBar" that extends
"phpillowDocument", I would expect those two functions to be called.
Nothing happens, though.

If I simply call spl_autoload_register instead of using
Zend_Loader_Autoload, everything works fine:

spl_autoload_register(function($class) {
    if (strpos($class, 'Model') === 0) {
        error_log("Loading $class");
        include APPLICATION_PATH . '/models/' . $class . '.php';
    }
    error_log('Tried to find class ' . $class);
});

Am I using the Autoload class wrong, or does it simply not work with
lambda functions yet?

CU
 Markus


Reply via email to