From d23e49850d02ac84b821687162d005b12d469783 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 28 Feb 2013 09:31:12 -0500 Subject: [PATCH] Created mechanism for reloading configuration through plugin manager. Note: this will create some inefficiency until \VuFind\Config\Reader is factored out of code; in some cases, configurations will load twice. Should be sorted out soon. --- .../VuFind/src/VuFind/Config/PluginFactory.php | 2 +- .../VuFind/src/VuFind/Config/PluginManager.php | 16 ++++++++++++++++ .../src/VuFind/Controller/AdminController.php | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/module/VuFind/src/VuFind/Config/PluginFactory.php b/module/VuFind/src/VuFind/Config/PluginFactory.php index 27bb59f5704..bf5f3c3ae7e 100644 --- a/module/VuFind/src/VuFind/Config/PluginFactory.php +++ b/module/VuFind/src/VuFind/Config/PluginFactory.php @@ -68,6 +68,6 @@ class PluginFactory implements AbstractFactoryInterface public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName ) { - return \VuFind\Config\Reader::getConfig($requestedName); + return \VuFind\Config\Reader::getConfig($requestedName, true); } } diff --git a/module/VuFind/src/VuFind/Config/PluginManager.php b/module/VuFind/src/VuFind/Config/PluginManager.php index d19396509f5..5e89f3b95b7 100644 --- a/module/VuFind/src/VuFind/Config/PluginManager.php +++ b/module/VuFind/src/VuFind/Config/PluginManager.php @@ -54,4 +54,20 @@ class PluginManager extends Base { // Assume everything is okay. } + + /** + * Reload a configuration and return the new version + * + * @param string $id Service identifier + * + * @return \Zend\Config\Config + */ + public function reload($id) + { + $oldOverrideSetting = $this->getAllowOverride(); + $this->setAllowOverride(true); + $this->setService($id, $this->create($id)); + $this->setAllowOverride($oldOverrideSetting); + return $this->get($id); + } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Controller/AdminController.php b/module/VuFind/src/VuFind/Controller/AdminController.php index 592cb9a10c7..52aca8f674c 100644 --- a/module/VuFind/src/VuFind/Controller/AdminController.php +++ b/module/VuFind/src/VuFind/Controller/AdminController.php @@ -262,7 +262,7 @@ class AdminController extends AbstractBase // Reload config now that it has been edited (otherwise, old setting // will persist in cache): - ConfigReader::getConfig(null, true); + $this->getServiceLocator()->get('VuFind\Config')->reload('config'); } else { $this->flashMessenger()->setNamespace('error') ->addMessage( -- GitLab