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

Finished IndexController -- it now forwards correctly. Note that this...

Finished IndexController -- it now forwards correctly.  Note that this required loading the latest master copy of the ZF2 Forward plug-in; the official version distributed with beta4 was broken.
parent a06d1867
Branches
Tags
No related merge requests found
......@@ -114,7 +114,8 @@ return array(
),
'controller' => array(
'classes' => array(
'index' => 'VuFind\Controller\IndexController'
'index' => 'VuFind\Controller\IndexController',
'search' => 'VuFind\Controller\SearchController'
),
),
'view_manager' => array(
......
......@@ -29,8 +29,7 @@ namespace VuFind\Controller;
use VuFind\Config\Reader as ConfigReader,
VuFind\Account\Manager as AccountManager,
Zend\Mvc\Controller\ActionController,
Zend\View\Model\ViewModel;
Zend\Mvc\Controller\ActionController;
/**
* Redirects the user to the appropriate default VuFind action.
......@@ -44,8 +43,8 @@ use VuFind\Config\Reader as ConfigReader,
class IndexController extends ActionController
{
/**
* Determines what elements are displayed on the
* home page based on if the user is logged in.
* Determines what elements are displayed on the home page based on whether
* the user is logged in.
*
* @return void
*/
......@@ -54,14 +53,11 @@ class IndexController extends ActionController
$config = ConfigReader::getConfig();
$loggedInModule = isset($config->Site->defaultLoggedInModule)
? $config->Site->defaultLoggedInModule : 'MyResearch';
$loggedInOpts = array('controller' => $loggedInModule, 'action' => 'Home');
$loggedOutModule = isset($config->Site->defaultModule)
? $config->Site->defaultModule : 'Search';
$loggedOutOpts = array('controller' => $loggedOutModule, 'action' => 'Home');
if (AccountManager::getInstance()->isLoggedIn()) {
return $this->forward()->dispatch('default', $loggedInOpts);
} else {
return $this->forward()->dispatch('default', $loggedOutOpts);
}
$module = AccountManager::getInstance()->isLoggedIn()
? $loggedInModule : $loggedOutModule;
$options = array('action' => 'Home', 'controller' => $module);
return $this->forward()->dispatch($module, $options);
}
}
<?php
/**
* Default Controller
*
* PHP version 5
*
* Copyright (C) Villanova University 2010.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Controller
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
namespace VuFind\Controller;
use Zend\Mvc\Controller\ActionController;
/**
* Redirects the user to the appropriate default VuFind action.
*
* @category VuFind2
* @package Controller
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
class SearchController extends ActionController
{
/**
* Home action
*
* @return void
*/
public function homeAction()
{
/* TODO:
$this->view->results = $this->getAdvancedFacets();
*/
}
}
......@@ -66,7 +66,7 @@ class Forward extends AbstractPlugin
*/
public function dispatch($name, array $params = null)
{
$event = $this->getEvent();
$event = clone($this->getEvent());
$locator = $this->getLocator();
$scoped = false;
......@@ -80,21 +80,18 @@ class Forward extends AbstractPlugin
if (!$controller instanceof Dispatchable) {
throw new Exception\DomainException('Can only forward to DispatchableInterface classes; class of type ' . get_class($controller) . ' received');
}
if ($controller instanceof InjectApplicationEventInterface) {
$controller->setEvent($event);
}
if (!$scoped) {
if ($controller instanceof InjectApplicationEventInterface) {
$controller->setEvent($event);
}
if ($controller instanceof ServiceLocatorAwareInterface) {
$controller->setServiceLocator($locator);
}
}
// Allow passing parameters to seed the RouteMatch with
$cachedMatches = false;
if ($params) {
$matches = new RouteMatch($params);
$cachedMatches = $event->getRouteMatch();
$event->setRouteMatch($matches);
$event->setRouteMatch(new RouteMatch($params));
}
if ($this->numNestedForwards > $this->maxNestedForwards) {
......@@ -106,10 +103,6 @@ class Forward extends AbstractPlugin
$this->numNestedForwards--;
if ($cachedMatches) {
$event->setRouteMatch($cachedMatches);
}
return $return;
}
......
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