1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\PageCache\Model;
/**
* Checks if session should be depersonalized in Depersonalize plugin
*/
class DepersonalizeChecker
{
/**
* Request
*
* @var \Magento\Framework\App\RequestInterface
*/
private $request;
/**
* Module manager
*
* @var \Magento\Framework\Module\Manager
*/
private $moduleManager;
/**
* Cache config
*
* @var Config
*/
private $cacheConfig;
/**
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\Module\Manager $moduleManager
* @param Config $cacheConfig
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\Module\Manager $moduleManager,
Config $cacheConfig
) {
$this->request = $request;
$this->moduleManager = $moduleManager;
$this->cacheConfig = $cacheConfig;
}
/**
* Check if depersonalize or not
*
* @param \Magento\Framework\View\LayoutInterface $subject
* @return bool
* @api
*/
public function checkIfDepersonalize(\Magento\Framework\View\LayoutInterface $subject)
{
return ($this->moduleManager->isEnabled('Magento_PageCache')
&& $this->cacheConfig->isEnabled()
&& !$this->request->isAjax()
&& ($this->request->isGet() || $this->request->isHead())
&& $subject->isCacheable());
}
}