Matthew Weier O'Phinney wrote:
> -- Cristian Bichis <contact@zftutorials.com> wrote
>
> Resource autoloading is different. It would be handled in one of two
> places: an initializer in your bootstrap, or via the "modules" bootstrap
> resource. This latter will (eventually) initialize a
> Zend_Application_Module_Autoloader instance (this is a concrete instance
> of Zend_Loader_Autoloader_Resource that has resources defined per the
> recommended directory structure) per module in your application, and, if
> a bootstrap class is available for that module, register it with that
> bootstrap.
>
> I say eventually, as neither Ben nor I have put together this last bit
> of functionality in the Modules resource yet.
>
Ok, so using code like this under bootstrap would be quite a standard
way ? No other way to simplify the code mroe than below:
protected function _initResources()
{
$this->bootstrapFrontController();
$loaders = array();
foreach ($this->front->getControllerDirectory() as $module => $dir)
{
$loaders[$module] = new Zend_Application_Module_Autoloader(
array(
'namespace' => ucfirst($module).'_',
'basePath' => dirname($dir),
) );
$loaders[$module]->addResourceType('Model', 'models', 'Model');
}
}
--
Best regards,
Cristian Bichis
www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
没有评论:
发表评论