I have modules as follow:
modules
default
controllers
IndexController
user
controllers
IndexController
If I put an action in the default IndexController called testAction() I can run that action at /index/test or default/index/test as expected.
If I put the same action in user IndexController and try and access it at user/index/test this fails to run testAction(). Instead it run indexAction() that is in the same controller. Why does it do that?
Extra info: I have an ini file located at application/configs/application.ini and the contents of it are:
[production]
phpSettings.date.timezone = 'Europe/Belfast'
phpSettings.display_startup_errors = 0
phpSettings.display_开发者_JS百科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]
I am running the application in development environment.
OK, I totally forgot something... I had a ACL plugin running preDispatch that was adding some routing rules! This is a fragment of the code that caused the problem:
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');
}
So you see, if the user was logged in they had no choice but to end up in the user/index/index action! Hope this saves someone else the same frustration.
resources.modules = ""
should be
resources.modules = []
精彩评论