我有以下模块:
modules
default
controllers
IndexController
user
controllers
IndexController
如果我将一个动作放在名为testAction()的默认IndexController中,我可以按照预期在/ index / test或default / index / test运行该动作。
如果我在用户IndexController中放入相同的操作并尝试在user / index / test访问它,则无法运行testAction()。相反,它运行在同一个控制器中的indexAction()。为什么这样做?
额外信息:我在application / configs / application.ini上有一个ini文件,其内容是:
[production]
phpSettings.date.timezone = 'Europe/Belfast'
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
;;namespaces
;site-wide namespaces
autoloaderNamespaces[] = "Plugin_"
autoloaderNamespaces[] = "Helper_"
;form validators
autoloaderNamespaces[] = "Validate_"
;modules
autoloaderNamespaces[] = "Users_"
autoloaderNamespaces[] = "Admin_"
;storage adapters
resources.db.adapter = mysqli
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password =
resources.db.params.dbname = vi
;modules
;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""
;layouts
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
resources.layout.layout = master
;routes
; /home route
resources.router.routes.home.route = /home
resources.router.routes.home.defaults.module = default
resources.router.routes.home.defaults.controller = index
resources.router.routes.home.defaults.action = index
; /content route
resources.router.routes.static-content.route = /content/:page
resources.router.routes.static-content.defaults.module = default
resources.router.routes.static-content.defaults.controller = static-content
resources.router.routes.static-content.defaults.action = display
;resources.frontController.plugins.CheckHasAccess = "Plugin_AccessCheck"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
[development : testing]
我正在开发环境中运行该应用程序。
答案 0 :(得分:0)
resources.modules = ""
应该是
resources.modules = []
答案 1 :(得分:0)
好的,我完全忘记了一些事情......我有一个运行preDispatch的ACL插件,它正在添加一些路由规则!这是导致问题的代码片段:
if (! $acl->isAllowed($role, $resouce, $action)) {
$request->setModuleName('default')
->setControllerName('auth')
->setActionName('login');
} else {
// if already logged in as user..
$request->setModuleName('user')
->setControllerName('index')
->setActionName('index');
}
所以你看,如果用户登录,他们别无选择,只能最终进入用户/索引/索引操作!希望这可以拯救别人同样的挫败感。