Skip to content

Commit f5df1a8

Browse files
jaimin-ktplmage2pratik
authored andcommitted
Removed direct use of SessionManager class, used SessionManagerInterface instead
1 parent 88ad7a6 commit f5df1a8

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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

@@ -36,10 +36,10 @@ public function __construct(
3636
/**
3737
* Delete frontend session cookie if customer session is expired
3838
*
39-
* @param SessionManager $sessionManager
39+
* @param SessionManagerInterface $sessionManager
4040
* @return void
4141
*/
42-
public function beforeStart(SessionManager $sessionManager)
42+
public function beforeStart(SessionManagerInterface $sessionManager)
4343
{
4444
if (!$this->cookieManager->getCookie($sessionManager->getName())
4545
&& $this->cookieManager->getCookie('mage-cache-sessid')
@@ -49,4 +49,4 @@ public function beforeStart(SessionManager $sessionManager)
4949
$this->cookieManager->deleteCookie('mage-cache-sessid', $metadata);
5050
}
5151
}
52-
}
52+
}

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: 7 additions & 4 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 $sessionManagerInterface
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
}
@@ -120,4 +123,4 @@ private function getErrorResponse()
120123
]
121124
);
122125
}
123-
}
126+
}

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

Lines changed: 5 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;

0 commit comments

Comments
 (0)