1

如何在 application.ini 中添加此资源类型。(在 Bootstrap.php 中工作,但如果可能的话,我更喜欢在 application.ini 中......)

protected function _initResourceLoader()
{
    $this->_resourceLoader->addResourceType( 'service', 'services/', 'Service' );
}
4

1 回答 1

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"
于 2012-04-28T07:12:18.513 回答