Zend Framework为模块配置了不同的配置文件

时间:2013-08-05 09:55:18

标签: zend-framework

我尝试使用模块结构构建我的应用程序并且我阅读了很多解决方案如何做到(我认为最好的解决方案是http://offshootinc.com/blog/2011/02/11/modul-bootstrapping-in-zend-framework/comment-page-1/)但是我遇到了一些问题,因为当我尝试设置一个Blog_Bootstrap_Initializer中的代码与Blog模块的不同默认控制器和操作:

protected function _initDefaultController(){
   $front = $this->getBootstrap()->getResource('frontcontroller');
   $front->setDefaultAction('index');
   $front->setDefaultControllerName('Auth');
   print "INITIALIZING Blog";
}

执行该方法是因为INITIALIZING Blog显示在屏幕上但代码没有效果。同样的情况是我尝试在application / modules / blog / configs / module.ini中设置

resources.frontController.defaultControllerName = 'Auth'
resources.frontController.defaultAction = 'login'

或者

blog.resources.frontController.defaultControllerName = 'Auth'
blog.resources.frontController.defaultAction = 'login'

的application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

appnamespace = "FA"

autoloadernamespaces[] = 'SilverCms'
autoloadernamespaces[] = 'FA'
autoloadernamespaces[] = 'Twitter'

; FrontController

; module enable

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.displayExceptions = 0

; default controller, action and module
resources.frontController.params.useDefaultControllerAlways = false
resources.frontController.params.prefixDefaultModule = false
resources.frontController.defaultModule = 'default'

resources.modules[] = ''
;resources.frontController.defaultControllerName = 'Index'
;resources.frontController.defaultAction = 'index'

; language plugin enable
resources.frontController.plugins.Language = SilverCms_Controller_Plugin_Language
; module plugin enable
;resources.frontController.plugins.ActiveModule = SilverCms_Controller_Plugin_ActiveModule
resources.frontController.baseurl = /zftest/public/


; Locale

resources.locale.default = "en_US"
resources.locale.force = false

; Translate

resources.translate.adapter = "Tmx"
resources.translate.data = APPLICATION_PATH "/modules"

resources.translate.locale = "auto"
resources.translate.disableNotices = true
resources.translate.scan = directory
;cahce
cache.enable = false

; Routes

resources.router.routes.module.type = Zend_Controller_Router_Route_Module
resources.router.routes.module.abstract = On    

resources.router.routes.language.type = Zend_Controller_Router_Route
resources.router.routes.language.route = ":language"
resources.router.routes.language.reqs.language = "^[a-z]{2}$"
resources.router.routes.language.defaults.language = "en"

resources.router.routes.default.type = Zend_Controller_Router_Route_Chain
resources.router.routes.default.chain = "language,module"


resources.router.routes.login.route = ':language/login/'
resources.router.routes.login.defaults.controller = 'Auth'
resources.router.routes.login.defaults.action = 'login'

; View

resources.view.helperPath.View_Helper = APPLICATION_PATH "/modules/default/views/helpers"

主要引导

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initPlugins()
    {
        $this->bootstrap('frontController');
        $front = Zend_Controller_Front::getInstance();
        $front->setControllerDirectory(array(
            'default' => APPLICATION_PATH .'/modules/default/controllers',
            'blog'    => APPLICATION_PATH .'/modules/blog/controllers',
            'billing' => APPLICATION_PATH .'/modules/billing/controllers',
        ));        
        $front->registerPlugin(new SilverCms_Controller_Plugin_ActiveModule());
        return $front;
    }

    protected function _initHelpers(){
        Zend_Controller_Action_HelperBroker::addPrefix('SilverCms_Controller_Action_Helper');
    }

}

模块中的主引导文件

class Blog_Bootstrap extends SilverCms_Application_Module_Bootstrap
{

}

模块(module.ini)中的配置文件

[production]
; uruchomienie domyslnego kontrolera gdy nie zostanie podany zaden inny
blog.resources.layout.layout = "blog"
blog.resources.layout.layoutPath = APPLICATION_PATH"/modules/blog/views/layouts/scripts"

blog.resources.frontController.defaultControllerName = 'Test'
blog.resources.frontController.defaultAction = 'test'


[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

我做错了什么?

0 个答案:

没有答案