Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36. Replaced _session with getSession(), removed some whitespace. #1

Merged
merged 1 commit into from
Aug 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions app/code/community/Studioforty9/Recaptcha/Helper/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Studioforty9_Recaptcha_Helper_Redirect extends Mage_Core_Helper_Abstract
{
/** @var Mage_Core_Model_Session $_session */
protected $_session;

/**
* Set the session object.
*
Expand All @@ -33,7 +33,7 @@ class Studioforty9_Recaptcha_Helper_Redirect extends Mage_Core_Helper_Abstract
public function setSession(Mage_Core_Model_Session_Abstract $session)
{
$this->_session = $session;

return $this;
}

Expand All @@ -47,10 +47,10 @@ public function getSession()
if (is_null($this->_session)) {
$this->_session = Mage::getSingleton('core/session');
}

return $this->_session;
}

/**
* Get the redirect URL.
*
Expand All @@ -59,20 +59,20 @@ public function getSession()
public function getUrl()
{
$referer = $this->_getRefererUrl();

if (! empty($referer)) {
return $referer;
}

if ($this->_session->hasLastUrl()) {
return $this->_session->getLastUrl();
if ($this->getSession()->hasLastUrl()) {
return $this->getSession()->getLastUrl();
}

return $this->getRequestUri();
}

/**
* Identify referer url via all accepted methods:
* Identify referer url via all accepted methods:
* - HTTP_REFERER
* - Regular
* - base64-encoded request param
Expand All @@ -82,7 +82,7 @@ public function getUrl()
protected function _getRefererUrl()
{
$request = Mage::app()->getRequest();

$refererUrl = $request->getServer('HTTP_REFERER');
if ($url = $request->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_REFERER_URL)) {
$refererUrl = $url;
Expand All @@ -93,7 +93,7 @@ protected function _getRefererUrl()
if ($url = $request->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED)) {
$refererUrl = Mage::helper('core')->urlDecode($url);
}

return $refererUrl;
}

Expand All @@ -105,11 +105,11 @@ protected function _getRefererUrl()
*/
protected function getRequestUri()
{
$visitorData = $this->_session->getData('visitor_data');
$visitorData = $this->getSession()->getData('visitor_data');

return ($this->hasRequestUri($visitorData)) ? $visitorData['request_uri'] : Mage::getBaseUrl();
}

/**
* Does the request have a valid request URI.
*
Expand Down