Skip to content

Commit

Permalink
ENGCOM-4354: [Backport] Removed direct use of SessionManager class, u…
Browse files Browse the repository at this point in the history
…sed SessionManagerInterface instead #21357
  • Loading branch information
sivaschenko authored Feb 23, 2019
2 parents 802fa5d + 0c7c2ab commit 935dceb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
11 changes: 8 additions & 3 deletions app/code/Magento/Customer/CustomerData/Plugin/SessionChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
*/
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;

/**
* Class SessionChecker
*/
class SessionChecker
{
/**
Expand Down Expand Up @@ -36,10 +39,12 @@ public function __construct(
/**
* Delete frontend session cookie if customer session is expired
*
* @param SessionManager $sessionManager
* @param SessionManagerInterface $sessionManager
* @return void
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException
*/
public function beforeStart(SessionManager $sessionManager)
public function beforeStart(SessionManagerInterface $sessionManager)
{
if (!$this->cookieManager->getCookie($sessionManager->getName())
&& $this->cookieManager->getCookie('mage-cache-sessid')
Expand Down
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 @@ -11,6 +11,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 @@ -39,7 +40,7 @@ class RequestSecureToken extends \Magento\Framework\App\Action\Action
private $secureTokenService;

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

Expand All @@ -55,19 +56,21 @@ class RequestSecureToken extends \Magento\Framework\App\Action\Action
* @param SecureToken $secureTokenService
* @param SessionManager $sessionManager
* @param Transparent $transparent
* @param SessionManagerInterface|null $sessionInterface
*/
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
9 changes: 7 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 Expand Up @@ -332,6 +335,8 @@ public function getModuleName()
}

/**
* Get Front Name
*
* @see getModuleName
*/
public function getFrontName()
Expand Down

0 comments on commit 935dceb

Please sign in to comment.