Skip to content

Commit

Permalink
More descriptive names for preDispatch action methods.
Browse files Browse the repository at this point in the history
- More readable, plus prevents conflicts between event handlers.
  • Loading branch information
demiankatz committed Apr 5, 2016
1 parent 78a186d commit 5d14edc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions module/VuFind/src/VuFind/Controller/AbstractBase.php
Expand Up @@ -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
Expand All @@ -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
);
}
}
Expand Down
6 changes: 4 additions & 2 deletions module/VuFind/src/VuFind/Controller/InstallController.php
Expand Up @@ -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:
Expand All @@ -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
);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions module/VuFind/src/VuFind/Controller/SummonController.php
Expand Up @@ -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.';
Expand All @@ -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
);
}

/**
Expand Down
Expand Up @@ -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.';
Expand All @@ -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
);
}
}
6 changes: 4 additions & 2 deletions module/VuFind/src/VuFind/Controller/UpgradeController.php
Expand Up @@ -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:
Expand All @@ -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
);
}

/**
Expand Down
Expand Up @@ -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;
Expand All @@ -77,7 +77,7 @@ public function preDispatch(MvcEvent $e)
}

// Call parent method to do permission checking:
parent::preDispatch($e);
parent::validateAccessPermission($e);
}

/**
Expand Down

0 comments on commit 5d14edc

Please sign in to comment.