2009年4月9日星期四

Re: [fw-mvc] Autoloading module resources with 1.8 Preview

I have just updated my code after Matthews earlier comments. So now I have:

modules
storefront
Bootstrap.php <- Main bootstrap subclasses
Zend_Application_Module_Bootstrap

and a config like:

bootstrap.path = APPLICATION_PATH"/modules/storefront/Bootstrap.php"
bootstrap.class = "Storefront_Bootstrap"

storefront.resources.frontcontroller.moduledirectory =
APPLICATION_PATH"/modules"
storefront.resources.frontcontroller.defaultmodule = "storefront"
storefront.resources.frontcontroller.throwexceptions = false
storefront.resources.frontcontroller.params.prefixDefaultModule = true
storefront.resources.frontcontroller.plugins.action = "SF_Plugin_Action"
storefront.resources.frontcontroller.plugins.admin = "SF_Plugin_AdminContext"

By doing it this way Zend_Application will auto register the
autoloaders for you :)

code is here http://code.google.com/p/zendframeworkstorefront/

Matthew, is this what you meant?

Thx

Keith


2009/4/9 Cristian Bichis <contact@zftutorials.com>:
> See my answer below...
>
> keith Pope wrote:
>
> 2009/4/9 Matthew Weier O'Phinney <matthew@zend.com>:
>
>
> -- keith Pope <mute.pop3@googlemail.com> wrote
> (on Wednesday, 08 April 2009, 10:17 PM +0100):
>
>
> The module resource skips the default module, you need to set that one
> up yourself, I think :)
>
>
> Your default module should be the one whose bootstrap you are attaching
> to Zend_Application typically.
>
>
> Indeed that makes more sense :) I look forward to your example
> hopefully I have got it mostly correct :)
>
>
> MyAutoloader is:
>
>    //set Autoloader
>     protected function _initAutoloader()
>     {
>         $this->_logger->info('Bootstrap ' . __METHOD__);
>
>         $this->bootstrap('frontcontroller');
>         $this->bootstrap('logging');
>
>         $this->_modules = array('admin' => MODULE_PATH . '/admin', 'default'
> => MODULE_PATH . '/default');
>
>         foreach ($this->_modules as $namespace => $path) {
>             $loader = new Zend_Application_Module_Autoloader(array(
>                 'namespace' => $namespace,
>                 'basePath'  => $path,
>             ));
>         }
>
>         return $this;
>     }
> But i still got that error...
>
> Fatal error: Class 'Admin_Model_Acl' not found in
> D:\_Work\yda\application\Bootstrap.php on line 163
>
> If i change this line
>
>         $this->_modules = array('Admin' => MODULE_PATH . '/admin', 'Default'
> => MODULE_PATH . '/default');
>
> I got this...
>
> Fatal error: Uncaught exception 'Zend_Controller_Exception' with message 'No
> default module defined for this application'
>
> Confusing...
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

没有评论: