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

Override routing to send user to error page when system is disabled.

parent 06e4bc3e
No related merge requests found
...@@ -22,6 +22,7 @@ $config = array( ...@@ -22,6 +22,7 @@ $config = array(
), ),
'controller' => array( 'controller' => array(
'classes' => array( 'classes' => array(
'error' => 'VuFind\Controller\ErrorController',
'index' => 'VuFind\Controller\IndexController', 'index' => 'VuFind\Controller\IndexController',
'search' => 'VuFind\Controller\SearchController' 'search' => 'VuFind\Controller\SearchController'
), ),
...@@ -56,7 +57,7 @@ $staticRoutes = array( ...@@ -56,7 +57,7 @@ $staticRoutes = array(
'Browse/Author', 'Browse/Dewey', 'Browse/Era', 'Browse/Genre', 'Browse/Home', 'Browse/Author', 'Browse/Dewey', 'Browse/Era', 'Browse/Genre', 'Browse/Home',
'Browse/LCC', 'Browse/Region', 'Browse/Tag', 'Browse/Topic', 'Browse/LCC', 'Browse/Region', 'Browse/Tag', 'Browse/Topic',
'Cart/Email', 'Cart/Export', 'Cart/Home', 'Cart/MyResearchBulk', 'Cart/Save', 'Cart/Email', 'Cart/Export', 'Cart/Home', 'Cart/MyResearchBulk', 'Cart/Save',
'Cover/Unavailable', 'Help/Home', 'Cover/Unavailable', 'Error/Unavailable', 'Help/Home',
'Install/Done', 'Install/FixBasicConfig', 'Install/FixCache', 'Install/Done', 'Install/FixBasicConfig', 'Install/FixCache',
'Install/FixDatabase', 'Install/FixDependencies', 'Install/FixILS', 'Install/FixDatabase', 'Install/FixDependencies', 'Install/FixILS',
'Install/FixSolr', 'Install/Home', 'Install/FixSolr', 'Install/Home',
......
...@@ -29,7 +29,7 @@ namespace VuFind; ...@@ -29,7 +29,7 @@ namespace VuFind;
use VuFind\Account\Manager as AccountManager, use VuFind\Account\Manager as AccountManager,
VuFind\Config\Reader as ConfigReader, VuFind\Config\Reader as ConfigReader,
VuFind\Theme\Initializer as ThemeInitializer, VuFind\Theme\Initializer as ThemeInitializer,
Zend\Mvc\MvcEvent; Zend\Mvc\MvcEvent, Zend\Mvc\Router\Http\RouteMatch;
/** /**
* VuFind Bootstrapper * VuFind Bootstrapper
* *
...@@ -73,6 +73,28 @@ class Bootstrap ...@@ -73,6 +73,28 @@ class Bootstrap
} }
} }
/**
* If the system is offline, set up a handler to override the routing output.
*
* @return void
*/
protected function initSystemStatus()
{
// If the system is unavailable, forward to a different place:
if (isset($this->config->System->available)
&& !$this->config->System->available
) {
$callback = function($e) {
$routeMatch = new RouteMatch(
array('controller' => 'Error', 'action' => 'Unavailable'), 1
);
$routeMatch->setMatchedRouteName('error-unavailable');
$e->setRouteMatch($routeMatch);
};
$this->events->attach('route', $callback);
}
}
/** /**
* Initializes locale and timezone values * Initializes locale and timezone values
* *
......
<?php
/**
* Error 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;
/**
* Error Controller
*
* @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 ErrorController extends ActionController
{
/**
* Display unavailable message.
*
* @return void
*/
public function unavailableAction()
{
// no special action necessary
}
}
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