Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data.php
Go to the documentation of this file.
1 <?php
11 
14 
20 {
21  const XML_PATH_ENABLED = 'persistent/options/enabled';
22 
23  const XML_PATH_LIFE_TIME = 'persistent/options/lifetime';
24 
25  const XML_PATH_LOGOUT_CLEAR = 'persistent/options/logout_clear';
26 
27  const XML_PATH_REMEMBER_ME_ENABLED = 'persistent/options/remember_enabled';
28 
29  const XML_PATH_REMEMBER_ME_DEFAULT = 'persistent/options/remember_default';
30 
31  const XML_PATH_PERSIST_SHOPPING_CART = 'persistent/options/shopping_cart';
32 
38  protected $_configFileName = 'persistent.xml';
39 
43  protected $_escaper;
44 
48  protected $_modulesReader;
49 
55  public function __construct(
56  \Magento\Framework\App\Helper\Context $context,
57  \Magento\Framework\Module\Dir\Reader $modulesReader,
58  \Magento\Framework\Escaper $escaper
59  ) {
60  $this->_modulesReader = $modulesReader;
61  $this->_escaper = $escaper;
62  parent::__construct(
63  $context
64  );
65  }
66 
74  public function isEnabled($store = null)
75  {
76  return $this->scopeConfig->isSetFlag(
77  self::XML_PATH_ENABLED,
79  $store
80  );
81  }
82 
90  public function isRememberMeEnabled($store = null)
91  {
92  return $this->scopeConfig->isSetFlag(
93  self::XML_PATH_REMEMBER_ME_ENABLED,
95  $store
96  );
97  }
98 
106  public function isRememberMeCheckedDefault($store = null)
107  {
108  return $this->scopeConfig->isSetFlag(
109  self::XML_PATH_REMEMBER_ME_DEFAULT,
111  $store
112  );
113  }
114 
122  public function isShoppingCartPersist($store = null)
123  {
124  return $this->scopeConfig->isSetFlag(
125  self::XML_PATH_PERSIST_SHOPPING_CART,
127  $store
128  );
129  }
130 
137  public function getLifeTime($store = null)
138  {
139  $lifeTime = intval(
140  $this->scopeConfig->getValue(
141  self::XML_PATH_LIFE_TIME,
143  $store
144  )
145  );
146  return $lifeTime < 0 ? 0 : $lifeTime;
147  }
148 
156  public function getClearOnLogout()
157  {
158  return $this->scopeConfig->isSetFlag(
159  self::XML_PATH_LOGOUT_CLEAR,
161  );
162  }
163 
170  public function getUnsetCookieUrl()
171  {
172  return $this->_getUrl('persistent/index/unsetCookie');
173  }
174 
180  public function getPersistentConfigFilePath()
181  {
182  return $this->_modulesReader->getModuleDir(Dir::MODULE_ETC_DIR, $this->_getModuleName())
183  . '/' . $this->_configFileName;
184  }
185 
194  public function canProcess($observer)
195  {
196  return true;
197  }
198 }
isRememberMeEnabled($store=null)
Definition: Data.php:90
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Module\Dir\Reader $modulesReader, \Magento\Framework\Escaper $escaper)
Definition: Data.php:55
getLifeTime($store=null)
Definition: Data.php:137
isRememberMeCheckedDefault($store=null)
Definition: Data.php:106
const XML_PATH_PERSIST_SHOPPING_CART
Definition: Data.php:31
isEnabled($store=null)
Definition: Data.php:74
isShoppingCartPersist($store=null)
Definition: Data.php:122