2009年2月28日星期六

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Thanks, works now.

What is probably missing now is an up to date documentation online, so we don't "waste" your time with non-bugs :)

Cristian

Matthew Weier O'Phinney wrote:
-- Cristian Bichis <contact@zftutorials.com> wrote (on Saturday, 28 February 2009, 12:36 PM +0200):   
     
 The problem is above -- the basePath should be a path _inside_ a given module, not a path *to* the modules (which is how you've defined MODULE_PATH). Change the above to:      'basePath' => MODULE_PATH . '/default'  and you should be fine.    
        $loader->addResourceType('Model', 'models', 'Model');         $plugins = new Default_Model_Plugins();        ................................................  I can't think to any change on bootstrap or index to led me to same error again... Which error was trapped by Zend_Loader::registerAutoload(), now gone.  I am using now latest from SVN.   -- Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com       -- Cristian Bichis <contact@zftutorials.com> wrote     (on Friday, 27 February 2009, 10:24 AM +0200):           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')                 ));       Okay, two things here. First, if you're going to use the Resource     autoloader, don't uses Zend_Loader::registerAutoload(); use     Zend_Loader_Autoloader -- and the latter is implicit when you     instantiate the resource autoloader.      Second, based on the resource types you're defining, you probably want     to use the Zend_Application_Module_Autoloader variant, as it has all of     the resources you indicated above defined already.      In the end, it would look like this:          $autoloader = new Zend_Application_Module_Autoloader(array(             'namespace' => 'Default_',             'basePath'  => MODULE_PATH,         ));      and that's it.       
   


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

没有评论: