From 5d14edc5d02e18af87d65669fe66510a090fdae6 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Tue, 5 Apr 2016 09:22:35 -0400 Subject: [PATCH] More descriptive names for preDispatch action methods. - More readable, plus prevents conflicts between event handlers. --- module/VuFind/src/VuFind/Controller/AbstractBase.php | 4 ++-- module/VuFind/src/VuFind/Controller/InstallController.php | 6 ++++-- module/VuFind/src/VuFind/Controller/SummonController.php | 6 ++++-- .../VuFind/src/VuFind/Controller/SummonrecordController.php | 6 ++++-- module/VuFind/src/VuFind/Controller/UpgradeController.php | 6 ++++-- .../src/VuFindAdmin/Controller/AbstractAdmin.php | 4 ++-- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index 226d1109c0b..de7259b5f11 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -64,7 +64,7 @@ class AbstractBase extends AbstractActionController * * @return void */ - public function preDispatch(MvcEvent $e) + public function validateAccessPermission(MvcEvent $e) { // Make sure the current user has permission to access the module: if ($this->accessPermission @@ -90,7 +90,7 @@ protected function attachDefaultListeners() if ($this->accessPermission) { $events = $this->getEventManager(); $events->attach( - MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000 + MvcEvent::EVENT_DISPATCH, [$this, 'validateAccessPermission'], 1000 ); } } diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 89f340d7eb9..96f9be03e56 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -49,7 +49,7 @@ class InstallController extends AbstractBase * * @return void */ - public function preDispatch(MvcEvent $e) + public function validateAutoConfigureConfig(MvcEvent $e) { // If auto-configuration is disabled, prevent any other action from being // accessed: @@ -71,7 +71,9 @@ protected function attachDefaultListeners() { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); + $events->attach( + MvcEvent::EVENT_DISPATCH, [$this, 'validateAutoConfigureConfig'], 1000 + ); } /** diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php index 3b3b804e8ac..f8294fb5bcd 100644 --- a/module/VuFind/src/VuFind/Controller/SummonController.php +++ b/module/VuFind/src/VuFind/Controller/SummonController.php @@ -69,7 +69,7 @@ protected function resultScrollerActive() * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function preDispatch(MvcEvent $e) + public function injectSummonMessage(MvcEvent $e) { $this->layout()->poweredBy = 'Powered by Summon™ from Serials Solutions, a division of ProQuest.'; @@ -84,7 +84,9 @@ protected function attachDefaultListeners() { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); + $events->attach( + MvcEvent::EVENT_DISPATCH, [$this, 'injectSummonMessage'], 1000 + ); } /** diff --git a/module/VuFind/src/VuFind/Controller/SummonrecordController.php b/module/VuFind/src/VuFind/Controller/SummonrecordController.php index 1368d5ece14..7d5bc02f421 100644 --- a/module/VuFind/src/VuFind/Controller/SummonrecordController.php +++ b/module/VuFind/src/VuFind/Controller/SummonrecordController.php @@ -73,7 +73,7 @@ protected function resultScrollerActive() * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function preDispatch(MvcEvent $e) + public function injectSummonMessage(MvcEvent $e) { $this->layout()->poweredBy = 'Powered by Summon™ from Serials Solutions, a division of ProQuest.'; @@ -88,6 +88,8 @@ protected function attachDefaultListeners() { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); + $events->attach( + MvcEvent::EVENT_DISPATCH, [$this, 'injectSummonMessage'], 1000 + ); } } diff --git a/module/VuFind/src/VuFind/Controller/UpgradeController.php b/module/VuFind/src/VuFind/Controller/UpgradeController.php index 4023f625f25..29e76900125 100644 --- a/module/VuFind/src/VuFind/Controller/UpgradeController.php +++ b/module/VuFind/src/VuFind/Controller/UpgradeController.php @@ -101,7 +101,7 @@ public function __construct(\VuFind\Cookie\CookieManager $cookieManager, * * @return void */ - public function preDispatch(MvcEvent $e) + public function validateAutoConfigureConfig(MvcEvent $e) { // If auto-configuration is disabled, prevent any other action from being // accessed: @@ -123,7 +123,9 @@ protected function attachDefaultListeners() { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); + $events->attach( + MvcEvent::EVENT_DISPATCH, [$this, 'validateAutoConfigureConfig'], 1000 + ); } /** diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/AbstractAdmin.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/AbstractAdmin.php index 53fa4bb7626..f3cda8fdd0c 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/AbstractAdmin.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/AbstractAdmin.php @@ -55,7 +55,7 @@ public function __construct() * * @return void */ - public function preDispatch(MvcEvent $e) + public function validateAccessPermission(MvcEvent $e) { // Disable search box in Admin module: $this->layout()->searchbox = false; @@ -77,7 +77,7 @@ public function preDispatch(MvcEvent $e) } // Call parent method to do permission checking: - parent::preDispatch($e); + parent::validateAccessPermission($e); } /**