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"
; A string used to format user interface time strings using the PHP date() function
; default is H:i (HH:MM 23:01)
displayTimeFormat = "H:i"
; The base VuFind URL will load the "Home" action of this module unless the user
; is logged in:
; The base VuFind URL will load this controller unless the user is logged in:
defaultModule = Search
; The base VuFind URL will load the "Home" action of this module when the user
; is logged in:
; When defaultModule is used, this action will be triggered (default = Home)
;defaultAction = Home
; The base VuFind URL will load this controller when the user is logged in:
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
; or omit to attempt to retain the user's current context after log out.
;logOutRoute = home
......
......@@ -75,12 +75,20 @@ class IndexController extends \Zend\Mvc\Controller\AbstractActionController
*/
public function homeAction()
{
$loggedInModule = isset($this->config->Site->defaultLoggedInModule)
? $this->config->Site->defaultLoggedInModule : 'MyResearch';
$loggedOutModule = isset($this->config->Site->defaultModule)
? $this->config->Site->defaultModule : 'Search';
$module = $this->authManager->isLoggedIn()
? $loggedInModule : $loggedOutModule;
return $this->forward()->dispatch($module, ['action' => 'Home']);
// Load different configurations depending on whether we're logged in or not:
if ($this->authManager->isLoggedIn()) {
$controller = isset($this->config->Site->defaultLoggedInModule)
? $this->config->Site->defaultLoggedInModule : 'MyResearch';
$actionConfig = 'defaultLoggedInAction';
} else {
$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