Skip to content
Snippets Groups Projects
Commit 906e6e14 authored by Demian Katz's avatar Demian Katz
Browse files

Add ability to configure default actions (not just controllers).

parent 1070c9ef
No related merge requests found
...@@ -86,12 +86,14 @@ displayDateFormat = "m-d-Y" ...@@ -86,12 +86,14 @@ displayDateFormat = "m-d-Y"
; A string used to format user interface time strings using the PHP date() function ; A string used to format user interface time strings using the PHP date() function
; default is H:i (HH:MM 23:01) ; default is H:i (HH:MM 23:01)
displayTimeFormat = "H:i" displayTimeFormat = "H:i"
; The base VuFind URL will load the "Home" action of this module unless the user ; The base VuFind URL will load this controller unless the user is logged in:
; is logged in:
defaultModule = Search defaultModule = Search
; The base VuFind URL will load the "Home" action of this module when the user ; When defaultModule is used, this action will be triggered (default = Home)
; is logged in: ;defaultAction = Home
; The base VuFind URL will load this controller when the user is logged in:
defaultLoggedInModule = MyResearch defaultLoggedInModule = MyResearch
; When defaultLoggedInModule is used, this action will be triggered (default = Home)
;defaultLoggedInAction = Home
; The route VuFind will send users to following a log out operation. Set to false ; The route VuFind will send users to following a log out operation. Set to false
; or omit to attempt to retain the user's current context after log out. ; or omit to attempt to retain the user's current context after log out.
;logOutRoute = home ;logOutRoute = home
......
...@@ -75,12 +75,20 @@ class IndexController extends \Zend\Mvc\Controller\AbstractActionController ...@@ -75,12 +75,20 @@ class IndexController extends \Zend\Mvc\Controller\AbstractActionController
*/ */
public function homeAction() public function homeAction()
{ {
$loggedInModule = isset($this->config->Site->defaultLoggedInModule) // Load different configurations depending on whether we're logged in or not:
? $this->config->Site->defaultLoggedInModule : 'MyResearch'; if ($this->authManager->isLoggedIn()) {
$loggedOutModule = isset($this->config->Site->defaultModule) $controller = isset($this->config->Site->defaultLoggedInModule)
? $this->config->Site->defaultModule : 'Search'; ? $this->config->Site->defaultLoggedInModule : 'MyResearch';
$module = $this->authManager->isLoggedIn() $actionConfig = 'defaultLoggedInAction';
? $loggedInModule : $loggedOutModule; } else {
return $this->forward()->dispatch($module, ['action' => 'Home']); $controller = isset($this->config->Site->defaultModule)
? $this->config->Site->defaultModule : 'Search';
$actionConfig = 'defaultAction';
}
$action = isset($this->config->Site->$actionConfig)
? $this->config->Site->$actionConfig : 'Home';
// Forward to the appropriate controller and action:
return $this->forward()->dispatch($controller, compact('action'));
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment