diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index 106dd6e4a9f106d1e353e5ffdb74cd38badc00c9..b2dfb7efd18deb9ed863039c3d157d0a0acff1a8 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -176,6 +176,18 @@ class AbstractBase extends AbstractActionController return $patron; } + /** + * Get a VuFind configuration. + * + * @param string $id Configuration identifier (default = main VuFind config) + * + * @return \Zend\Config\Config + */ + public function getConfig($id = 'config') + { + return $this->getServiceLocator()->get('VuFind\Config')->get($id); + } + /** * Get the ILS connection. * diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index fdd84b6db3bf1dc1a708885384ab96eaa94efa9f..1b5bd949c8ba5acbc31a4bb90a3b87ce3718692b 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -345,7 +345,7 @@ class AbstractRecord extends AbstractBase public function emailAction() { // Force login if necessary: - $config = \VuFind\Config\Reader::getConfig(); + $config = $this->getConfig(); if ((!isset($config->Mail->require_login) || $config->Mail->require_login) && !$this->getUser() ) { diff --git a/module/VuFind/src/VuFind/Controller/AdminController.php b/module/VuFind/src/VuFind/Controller/AdminController.php index 8097f5c89659575dc4374e3273f1421a9de3c615..592cb9a10c767ad0e0ec2250a7824a25258b3e37 100644 --- a/module/VuFind/src/VuFind/Controller/AdminController.php +++ b/module/VuFind/src/VuFind/Controller/AdminController.php @@ -61,7 +61,7 @@ class AdminController extends AbstractBase } // Block access to everyone when module is disabled: - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); if (!isset($config->Site->admin_enabled) || !$config->Site->admin_enabled) { $routeMatch->setParam('action', 'disabled'); return; @@ -127,7 +127,7 @@ class AdminController extends AbstractBase */ public function homeAction() { - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $xml = false; if (isset($config->Index->url)) { $response = $this->getServiceLocator()->get('VuFind\Http') @@ -162,7 +162,7 @@ class AdminController extends AbstractBase { $view = $this->createViewModel(); - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $statsFilled = array( 'search' => false, 'record' => false @@ -240,7 +240,7 @@ class AdminController extends AbstractBase { $view = $this->createViewModel(); $view->baseConfigPath = ConfigReader::getBaseConfigPath(''); - $conf = ConfigReader::getConfig(); + $conf = $this->getConfig(); $view->showInstallLink = isset($conf->System->autoConfigure) && $conf->System->autoConfigure; return $view; diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index 5d19f4e1248ed1f0594b0f9a63dbf2cebf3d760a..04d3287c9b9b0ee418fdef5b80a07ac3097e1573 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -26,8 +26,7 @@ * @link http://vufind.org/wiki/vufind2:building_a_controller Wiki */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader, - VuFind\Exception\Auth as AuthException; +use VuFind\Exception\Auth as AuthException; /** * This controller handles global AJAX functionality @@ -209,7 +208,7 @@ class AjaxController extends AbstractBase ); // Load callnumber and location settings: - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $callnumberSetting = isset($config->Item_Status->multiple_call_nos) ? $config->Item_Status->multiple_call_nos : 'msg'; $locationSetting = isset($config->Item_Status->multiple_locations) @@ -1257,7 +1256,7 @@ class AjaxController extends AbstractBase $this->writeSession(); // avoid session write timing bug $openUrl = $this->params()->fromQuery('openurl', ''); - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $resolverType = isset($config->OpenURL->resolver) ? $config->OpenURL->resolver : 'other'; $pluginManager = $this->getServiceLocator() diff --git a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php index 0c91ade93bceba1d1845206d255f9a3dc26a8ec7..48746be06c83f0a9c8c51f3993bd100686e7800e 100644 --- a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php +++ b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php @@ -27,8 +27,7 @@ * @link http://vufind.org/wiki/alphabetical_heading_browse Wiki */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader, - VuFind\Connection\Manager as ConnectionManager, +use VuFind\Connection\Manager as ConnectionManager, VuFind\Exception\Solr as SolrException; /** @@ -52,7 +51,7 @@ class AlphabrowseController extends AbstractBase */ public function homeAction() { - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); // Load browse types from config file, or use defaults if unavailable: if (isset($config->AlphaBrowse_Types) diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php index cd8895959c9e3d5fe01a606af3c00a2556624668..f2fb501a8d82aa77a8c9f02c158be30cebc5f344 100644 --- a/module/VuFind/src/VuFind/Controller/CartController.php +++ b/module/VuFind/src/VuFind/Controller/CartController.php @@ -167,7 +167,7 @@ class CartController extends AbstractBase public function emailAction() { // Force login if necessary: - $config = \VuFind\Config\Reader::getConfig(); + $config = $this->getConfig(); if ((!isset($config->Mail->require_login) || $config->Mail->require_login) && !$this->getUser() ) { diff --git a/module/VuFind/src/VuFind/Controller/CoverController.php b/module/VuFind/src/VuFind/Controller/CoverController.php index 60508d259ac92c76ad312a2a6fca9aa18b18a9eb..2efe5dae265f3422f5b07f7637b66fa16b2c62bc 100644 --- a/module/VuFind/src/VuFind/Controller/CoverController.php +++ b/module/VuFind/src/VuFind/Controller/CoverController.php @@ -26,7 +26,7 @@ * @link http://www.vufind.org Main Page */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader, VuFind\Cover\Loader; +use VuFind\Cover\Loader; /** * Generates covers for book entries @@ -51,7 +51,7 @@ class CoverController extends AbstractBase // Construct object for loading cover images if it does not already exist: if (!$this->loader) { $this->loader = new Loader( - ConfigReader::getConfig(), + $this->getConfig(), $this->getServiceLocator()->get('VuFindTheme\ThemeInfo'), $this->getServiceLocator()->get('VuFind\Http')->createClient(), $this->getServiceLocator()->get('VuFind\CacheManager')->getCacheDir() diff --git a/module/VuFind/src/VuFind/Controller/HierarchyController.php b/module/VuFind/src/VuFind/Controller/HierarchyController.php index a1b6c5a3c3f772ff833ad695c8bb427588003683..0fae2b3587e43e1b00eb08f9e80fee1e2bc412d1 100644 --- a/module/VuFind/src/VuFind/Controller/HierarchyController.php +++ b/module/VuFind/src/VuFind/Controller/HierarchyController.php @@ -79,7 +79,7 @@ class HierarchyController extends AbstractBase public function searchtreeAction() { $this->writeSession(); // avoid session write timing bug - $config = \VuFind\Config\Reader::getConfig(); + $config = $this->getConfig(); $limit = isset($config->Hierarchy->treeSearchLimit) ? $config->Hierarchy->treeSearchLimit : -1; $resultIDs = array(); diff --git a/module/VuFind/src/VuFind/Controller/IndexController.php b/module/VuFind/src/VuFind/Controller/IndexController.php index 17c52e526e84790f2a2f4d118f730ecdf4e6a0b5..ac6f7a3d2fa293047ade64e510ae8a4b000421d3 100644 --- a/module/VuFind/src/VuFind/Controller/IndexController.php +++ b/module/VuFind/src/VuFind/Controller/IndexController.php @@ -27,8 +27,6 @@ */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader; - /** * Redirects the user to the appropriate default VuFind action. * @@ -48,7 +46,7 @@ class IndexController extends AbstractBase */ public function homeAction() { - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $loggedInModule = isset($config->Site->defaultLoggedInModule) ? $config->Site->defaultLoggedInModule : 'MyResearch'; $loggedOutModule = isset($config->Site->defaultModule) diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 0cb93d909fa64fb2b7cb01f749ef258da541033a..cf4600a80916875740340b33e452909965546256 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -56,7 +56,7 @@ class InstallController extends AbstractBase { // If auto-configuration is disabled, prevent any other action from being // accessed: - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); if (!isset($config->System->autoConfigure) || !$config->System->autoConfigure ) { @@ -115,7 +115,7 @@ class InstallController extends AbstractBase // See if the URL setting remains at the default (unless we already // know we've failed): if ($status) { - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); if (stristr($config->Site->url, 'myuniversity.edu')) { $status = false; } @@ -428,7 +428,7 @@ class InstallController extends AbstractBase */ protected function checkILS() { - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); if (in_array($config->Catalog->driver, array('Sample', 'Demo'))) { $status = false; } else { @@ -473,7 +473,7 @@ class InstallController extends AbstractBase // If we got this far, check whether we have an error with a real driver // or if we need to warn the user that they have selected a fake driver: - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $view = $this->createViewModel(); if (in_array($config->Catalog->driver, array('Sample', 'Demo'))) { $view->demo = true; @@ -526,7 +526,7 @@ class InstallController extends AbstractBase public function fixsolrAction() { // In Windows, localhost may fail -- see if switching to 127.0.0.1 helps: - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $configFile = ConfigReader::getLocalConfigPath('config.ini', null, true); if (stristr($config->Index->url, 'localhost')) { $newUrl = str_replace('localhost', '127.0.0.1', $config->Index->url); @@ -569,7 +569,7 @@ class InstallController extends AbstractBase protected function checkSecurity() { // Are configuration settings missing? - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); if (!isset($config->Authentication->hash_passwords) || !$config->Authentication->hash_passwords || !isset($config->Authentication->encrypt_ils_password) @@ -665,7 +665,7 @@ class InstallController extends AbstractBase public function performsecurityfixAction() { // First, set encryption/hashing to true, and set the key - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $configPath = ConfigReader::getLocalConfigPath('config.ini', null, true); $writer = new ConfigWriter($configPath); if ($this->fixSecurityConfiguration($config, $writer)) { diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 23daa5ddf49bf2cb45b6af936eaa4c0a41b062c4..ed5699b92317e1e976e384139f782e3c8a0cfd11 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -27,8 +27,7 @@ */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader, - VuFind\Exception\Auth as AuthException, +use VuFind\Exception\Auth as AuthException, VuFind\Exception\ListPermission as ListPermissionException, VuFind\Exception\RecordMissing as RecordMissingException, Zend\Stdlib\Parameters; @@ -81,7 +80,7 @@ class MyResearchController extends AbstractBase return $this->redirect()->toUrl($url); } - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $page = isset($config->Site->defaultAccountPage) ? $config->Site->defaultAccountPage : 'Favorites'; return $this->forwardTo('MyResearch', $page); diff --git a/module/VuFind/src/VuFind/Controller/OaiController.php b/module/VuFind/src/VuFind/Controller/OaiController.php index 653d714df0c868296062bd84ed685ff8e0be725a..2ce781103c72816d61f20d1b58342105de6e24b2 100644 --- a/module/VuFind/src/VuFind/Controller/OaiController.php +++ b/module/VuFind/src/VuFind/Controller/OaiController.php @@ -26,7 +26,6 @@ * @link http://vufind.org/wiki/vufind2:building_a_controller Wiki */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader; /** * OAIController Class @@ -82,7 +81,7 @@ class OaiController extends AbstractBase protected function handleOAI($serverClass) { // Check if the OAI Server is enabled before continuing - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $response = $this->getResponse(); if (!isset($config->OAI)) { $response->setStatusCode(404); diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index fcf2fadb56e2d3b965b26d50c339c568c58254ec..9d6ed37f24e9e0ed2c6b582925f42b9f521c9d80 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -27,8 +27,7 @@ */ namespace VuFind\Controller; -use VuFind\Config\Reader as ConfigReader, - VuFind\Exception\Mail as MailException, VuFind\Search\Memory, +use VuFind\Exception\Mail as MailException, VuFind\Search\Memory, VuFind\Solr\Utils as SolrUtils; /** @@ -85,7 +84,7 @@ class SearchController extends AbstractSearch ); // Force login if necessary: - $config = \VuFind\Config\Reader::getConfig(); + $config = $this->getConfig(); if ((!isset($config->Mail->require_login) || $config->Mail->require_login) && !$this->getUser() ) { @@ -311,7 +310,7 @@ class SearchController extends AbstractSearch // Find out if there are user configured range options; if not, // default to the standard 1/5/30 days: $ranges = array(); - $searchSettings = ConfigReader::getConfig('searches'); + $searchSettings = $this->getConfig('searches'); if (isset($searchSettings->NewItem->ranges)) { $tmp = explode(',', $searchSettings->NewItem->ranges); foreach ($tmp as $range) { @@ -342,7 +341,7 @@ class SearchController extends AbstractSearch $range = $this->params()->fromQuery('range'); $dept = $this->params()->fromQuery('department'); - $searchSettings = ConfigReader::getConfig('searches'); + $searchSettings = $this->getConfig('searches'); // The code always pulls in enough catalog results to get a fixed number // of pages worth of Solr results. Note that if the Solr index is out of @@ -583,7 +582,7 @@ class SearchController extends AbstractSearch { switch ($this->params()->fromQuery('method')) { case 'describe': - $config = ConfigReader::getConfig(); + $config = $this->getConfig(); $xml = $this->getViewRenderer()->render( 'search/opensearch-describe.phtml', array('site' => $config->Site) );