Skip to content

Commit 935dceb

Browse files
authored
ENGCOM-4354: [Backport] Removed direct use of SessionManager class, used SessionManagerInterface instead #21357
2 parents 802fa5d + 0c7c2ab commit 935dceb

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

app/code/Magento/Customer/CustomerData/Plugin/SessionChecker.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
*/
66
namespace Magento\Customer\CustomerData\Plugin;
77

8-
use Magento\Framework\Session\SessionManager;
8+
use Magento\Framework\Session\SessionManagerInterface;
99
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
1010
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
1111

12+
/**
13+
* Class SessionChecker
14+
*/
1215
class SessionChecker
1316
{
1417
/**
@@ -36,10 +39,12 @@ public function __construct(
3639
/**
3740
* Delete frontend session cookie if customer session is expired
3841
*
39-
* @param SessionManager $sessionManager
42+
* @param SessionManagerInterface $sessionManager
4043
* @return void
44+
* @throws \Magento\Framework\Exception\InputException
45+
* @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException
4146
*/
42-
public function beforeStart(SessionManager $sessionManager)
47+
public function beforeStart(SessionManagerInterface $sessionManager)
4348
{
4449
if (!$this->cookieManager->getCookie($sessionManager->getName())
4550
&& $this->cookieManager->getCookie('mage-cache-sessid')

app/code/Magento/Customer/etc/frontend/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<type name="Magento\Checkout\Block\Cart\Sidebar">
5858
<plugin name="customer_cart" type="Magento\Customer\Model\Cart\ConfigPlugin" />
5959
</type>
60-
<type name="Magento\Framework\Session\SessionManager">
60+
<type name="Magento\Framework\Session\SessionManagerInterface">
6161
<plugin name="session_checker" type="Magento\Customer\CustomerData\Plugin\SessionChecker" />
6262
</type>
6363
<type name="Magento\Authorization\Model\CompositeUserContext">
@@ -77,4 +77,4 @@
7777
</argument>
7878
</arguments>
7979
</type>
80-
</config>
80+
</config>

app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Controller\ResultInterface;
1212
use Magento\Framework\Session\Generic;
1313
use Magento\Framework\Session\SessionManager;
14+
use Magento\Framework\Session\SessionManagerInterface;
1415
use Magento\Paypal\Model\Payflow\Service\Request\SecureToken;
1516
use Magento\Paypal\Model\Payflow\Transparent;
1617
use Magento\Quote\Model\Quote;
@@ -39,7 +40,7 @@ class RequestSecureToken extends \Magento\Framework\App\Action\Action
3940
private $secureTokenService;
4041

4142
/**
42-
* @var SessionManager
43+
* @var SessionManager|SessionManagerInterface
4344
*/
4445
private $sessionManager;
4546

@@ -55,19 +56,21 @@ class RequestSecureToken extends \Magento\Framework\App\Action\Action
5556
* @param SecureToken $secureTokenService
5657
* @param SessionManager $sessionManager
5758
* @param Transparent $transparent
59+
* @param SessionManagerInterface|null $sessionInterface
5860
*/
5961
public function __construct(
6062
Context $context,
6163
JsonFactory $resultJsonFactory,
6264
Generic $sessionTransparent,
6365
SecureToken $secureTokenService,
6466
SessionManager $sessionManager,
65-
Transparent $transparent
67+
Transparent $transparent,
68+
SessionManagerInterface $sessionInterface = null
6669
) {
6770
$this->resultJsonFactory = $resultJsonFactory;
6871
$this->sessionTransparent = $sessionTransparent;
6972
$this->secureTokenService = $secureTokenService;
70-
$this->sessionManager = $sessionManager;
73+
$this->sessionManager = $sessionInterface ?: $sessionManager;
7174
$this->transparent = $transparent;
7275
parent::__construct($context);
7376
}

lib/internal/Magento/Framework/View/Context.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Event\ManagerInterface;
1515
use Psr\Log\LoggerInterface as Logger;
1616
use Magento\Framework\Session\SessionManager;
17+
use Magento\Framework\Session\SessionManagerInterface;
1718
use Magento\Framework\TranslateInterface;
1819
use Magento\Framework\UrlInterface;
1920
use Magento\Framework\View\ConfigInterface as ViewConfig;
@@ -144,6 +145,7 @@ class Context
144145
* @param Logger $logger
145146
* @param AppState $appState
146147
* @param LayoutInterface $layout
148+
* @param SessionManagerInterface|null $sessionManager
147149
*
148150
* @todo reduce parameter number
149151
*
@@ -163,15 +165,16 @@ public function __construct(
163165
CacheState $cacheState,
164166
Logger $logger,
165167
AppState $appState,
166-
LayoutInterface $layout
168+
LayoutInterface $layout,
169+
SessionManagerInterface $sessionManager = null
167170
) {
168171
$this->request = $request;
169172
$this->eventManager = $eventManager;
170173
$this->urlBuilder = $urlBuilder;
171174
$this->translator = $translator;
172175
$this->cache = $cache;
173176
$this->design = $design;
174-
$this->session = $session;
177+
$this->session = $sessionManager ?: $session;
175178
$this->scopeConfig = $scopeConfig;
176179
$this->frontController = $frontController;
177180
$this->viewConfig = $viewConfig;
@@ -332,6 +335,8 @@ public function getModuleName()
332335
}
333336

334337
/**
338+
* Get Front Name
339+
*
335340
* @see getModuleName
336341
*/
337342
public function getFrontName()

0 commit comments

Comments
 (0)