Skip to content

Commit

Permalink
Removed direct use of SessionManager class, used SessionManagerInterf…
Browse files Browse the repository at this point in the history
…ace instead
  • Loading branch information
jaimin-ktpl committed Jan 27, 2019
1 parent b8892f0 commit 8b30520
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\Customer\CustomerData\Plugin;

use Magento\Framework\Session\SessionManager;
use Magento\Framework\Session\SessionManagerInterface;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;

Expand Down Expand Up @@ -36,10 +36,10 @@ public function __construct(
/**
* Delete frontend session cookie if customer session is expired
*
* @param SessionManager $sessionManager
* @param SessionManagerInterface $sessionManager
* @return void
*/
public function beforeStart(SessionManager $sessionManager)
public function beforeStart(SessionManagerInterface $sessionManager)
{
if (!$this->cookieManager->getCookie($sessionManager->getName())
&& $this->cookieManager->getCookie('mage-cache-sessid')
Expand All @@ -49,4 +49,4 @@ public function beforeStart(SessionManager $sessionManager)
$this->cookieManager->deleteCookie('mage-cache-sessid', $metadata);
}
}
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<type name="Magento\Checkout\Block\Cart\Sidebar">
<plugin name="customer_cart" type="Magento\Customer\Model\Cart\ConfigPlugin" />
</type>
<type name="Magento\Framework\Session\SessionManager">
<type name="Magento\Framework\Session\SessionManagerInterface">
<plugin name="session_checker" type="Magento\Customer\CustomerData\Plugin\SessionChecker" />
</type>
<type name="Magento\Authorization\Model\CompositeUserContext">
Expand All @@ -77,4 +77,4 @@
</argument>
</arguments>
</type>
</config>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Session\Generic;
use Magento\Framework\Session\SessionManager;
use Magento\Framework\Session\SessionManagerInterface;
use Magento\Paypal\Model\Payflow\Service\Request\SecureToken;
use Magento\Paypal\Model\Payflow\Transparent;
use Magento\Quote\Model\Quote;
Expand Down Expand Up @@ -40,7 +41,7 @@ class RequestSecureToken extends \Magento\Framework\App\Action\Action implements
private $secureTokenService;

/**
* @var SessionManager
* @var SessionManager|SessionManagerInterface
*/
private $sessionManager;

Expand All @@ -56,19 +57,21 @@ class RequestSecureToken extends \Magento\Framework\App\Action\Action implements
* @param SecureToken $secureTokenService
* @param SessionManager $sessionManager
* @param Transparent $transparent
* @param SessionManagerInterface|null $sessionManagerInterface
*/
public function __construct(
Context $context,
JsonFactory $resultJsonFactory,
Generic $sessionTransparent,
SecureToken $secureTokenService,
SessionManager $sessionManager,
Transparent $transparent
Transparent $transparent,
SessionManagerInterface $sessionInterface = null
) {
$this->resultJsonFactory = $resultJsonFactory;
$this->sessionTransparent = $sessionTransparent;
$this->secureTokenService = $secureTokenService;
$this->sessionManager = $sessionManager;
$this->sessionManager = $sessionInterface ?: $sessionManager;
$this->transparent = $transparent;
parent::__construct($context);
}
Expand Down Expand Up @@ -119,4 +122,4 @@ private function getErrorResponse()
]
);
}
}
}
7 changes: 5 additions & 2 deletions lib/internal/Magento/Framework/View/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\Framework\Event\ManagerInterface;
use Psr\Log\LoggerInterface as Logger;
use Magento\Framework\Session\SessionManager;
use Magento\Framework\Session\SessionManagerInterface;
use Magento\Framework\TranslateInterface;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\ConfigInterface as ViewConfig;
Expand Down Expand Up @@ -144,6 +145,7 @@ class Context
* @param Logger $logger
* @param AppState $appState
* @param LayoutInterface $layout
* @param SessionManagerInterface|null $sessionManager
*
* @todo reduce parameter number
*
Expand All @@ -163,15 +165,16 @@ public function __construct(
CacheState $cacheState,
Logger $logger,
AppState $appState,
LayoutInterface $layout
LayoutInterface $layout,
SessionManagerInterface $sessionManager = null
) {
$this->request = $request;
$this->eventManager = $eventManager;
$this->urlBuilder = $urlBuilder;
$this->translator = $translator;
$this->cache = $cache;
$this->design = $design;
$this->session = $session;
$this->session = $sessionManager ?: $session;
$this->scopeConfig = $scopeConfig;
$this->frontController = $frontController;
$this->viewConfig = $viewConfig;
Expand Down

0 comments on commit 8b30520

Please sign in to comment.