2009年2月27日星期五

[fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Hi,

I tried last days to get in touch with some newer (or TBA) features of ZF. One of them is Zend_Loader_Autoloader_Resource.

I made a sample for a modular archtecture. I am trying as a demonstration to load a Plugins model from /application/modules/default/models

That's into application/Bootstrap.php:

        Zend_Loader::registerAutoload();
       
        $autoloader = new Zend_Loader_Autoloader_Resource(
            array(
            'namespace'   => 'Default',
            'basePath' => MODULE_PATH
            )
        );
       
        $autoloader->addResourceTypes(array(
                'Model' => array('path' => 'models', 'namespace' => 'Model'),
                'DbTable'  => array('path' => 'models/DbTable', 'namespace' => 'DbTable')
        ));

Into a controller plugin in am making use of resource autoloader this way:

$plugins = new Default_Model_Plugins();


Now here are my questions:
1. Why i am receiving this error:

Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [function.include]: failed to open stream: No such file or directory in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173

I am not sure why is not included the "default" into path... Or anyway, what i am missing ?

2. There is any other error ? Like namespace been 'namespace'   => 'Default' or  'namespace'   => 'Default_', as according to sample from incubator file ('namespace' => 'Stuff_').

3. How should be the class name of the model ? Plugins ? Or Default_Plugins ? or Default_Model_Plugins ?

Thanks for help.
--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

没有评论: