如何在application.ini中添加此资源类型。 (在Bootstrap.php中工作但我更喜欢在application.ini中,如果可能的话......)
protected function _initResourceLoader()
{
$this->_resourceLoader->addResourceType( 'service', 'services/', 'Service' );
}
答案 0 :(得分:1)
您可以创建自己的应用程序资源:
class My_Resource_Resourceloader extends Zend_Application_Resource_ResourceAbstract
{
public function init()
{
$options = $this->getOptions();
/* @var $resourceLoader Zend_Loader_Autoloader_Resource */
$resourceLoader = $this->getBootstrap()->getResourceLoader();
foreach ($options as $method => $params) {
if (method_exists($resourceLoader, $method)) {
call_user_func_array(array($resourceLoader, $method), $params);
}
}
}
}
在application.ini中指定资源路径:
pluginpaths.My_Resource = "My/Resource"
配置单一资源:
resources.resourceloader.addResourceType.1 = "service"
resources.resourceloader.addResourceType.2 = "services/"
resources.resourceloader.addResourceType.3 = "Service"
配置多个资源:
resources.resourceloader.addResourceTypes.1.acl.path = "acls/"
resources.resourceloader.addResourceTypes.1.acl.namespace = "Acl"
resources.resourceloader.addResourceTypes.1.service.path = "services/"
resources.resourceloader.addResourceTypes.1.service.namespace = "Service"