Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-store
Model
StoreSwitcher
ManagePrivateContent.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\Store\Model\StoreSwitcher
;
9
10
use
Magento\Store\Model\StoreSwitcherInterface
;
11
use
Magento\Store\Api\Data\StoreInterface
;
12
16
class
ManagePrivateContent
implements
StoreSwitcherInterface
17
{
21
private
$cookieMetadataFactory;
22
26
private
$cookieManager;
27
32
public
function
__construct
(
33
\
Magento
\Framework\Stdlib\Cookie\
CookieMetadataFactory
$cookieMetadataFactory,
34
\
Magento
\Framework\Stdlib\
CookieManagerInterface
$cookieManager
35
) {
36
$this->cookieMetadataFactory = $cookieMetadataFactory;
37
$this->cookieManager = $cookieManager;
38
}
39
47
public
function
switch
(
StoreInterface
$fromStore,
StoreInterface
$targetStore,
string
$redirectUrl):
string
48
{
49
try
{
50
$publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()
51
->setDurationOneYear()
52
->setPath(
'/'
)
53
->setSecure(
false
)
54
->setHttpOnly(
false
);
55
$this->cookieManager->setPublicCookie(
56
\
Magento
\Framework\
App
\PageCache\Version::COOKIE_NAME,
57
'should_be_updated'
,
58
$publicCookieMetadata
59
);
60
}
catch
(\Exception $e) {
61
throw
new
CannotSwitchStoreException
($e);
62
}
63
64
return
$redirectUrl;
65
}
66
}
Magento\Framework\App
Magento\Store\Model\StoreSwitcher\CannotSwitchStoreException
Definition:
CannotSwitchStoreException.php:16
Magento\Store\Model\StoreSwitcher\ManagePrivateContent
Definition:
ManagePrivateContent.php:16
Magento\Store\Model\StoreSwitcherInterface
Definition:
StoreSwitcherInterface.php:16
Magento\Framework\Stdlib\CookieManagerInterface
Definition:
CookieManagerInterface.php:27
Magento\Store\Model\StoreSwitcher\ManagePrivateContent\__construct
__construct(\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager)
Definition:
ManagePrivateContent.php:32
Magento
Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
Definition:
CookieMetadataFactory.php:16
Magento\Store\Api\Data\StoreInterface
Definition:
StoreInterface.php:14
Magento\Store\Model\StoreSwitcher
Definition:
CannotSwitchStoreException.php:8