When adding new resource types, we have to add them into all modules
bootstrap.
It would be nice to add them only once and that ZF automatically resolves
for modules namespaces. Just like the default resource types.
e.g:
Application's bootstrap :
[code]
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => dirname(__FILE__),
));
$autoloader->addResourceType('repository', 'repositories',
'Repository');
return $autoloader;
}
[/code]
Then:
application/
modules/
backend/
repositories/
Test.php
repositories/
Test.php
[code]
new Repository_Test(); // OK
new Backend_Repository_Test(); // Fatal error
[/code]
I also have to add the resource type into "Backend" module's bootstrap :
[code]
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Backend_',
'basePath' => dirname(__FILE__)
));
$autoloader->addResourceType('repository', 'repositories',
'Repository');
return $autoloader;
}
[/code]
That's not very convenient :)
Thanks.
BR,
Benjamin.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/New-resource-types-and-modules-based-application-tp2953049p2953049.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论