Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 
11 use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
12 
16 class Config implements \Cm\RedisSession\Handler\ConfigInterface
17 {
21  const PARAM_LOG_LEVEL = 'session/redis/log_level';
22 
26  const PARAM_HOST = 'session/redis/host';
27 
31  const PARAM_PORT = 'session/redis/port';
32 
36  const PARAM_DATABASE = 'session/redis/database';
37 
41  const PARAM_PASSWORD = 'session/redis/password';
42 
46  const PARAM_TIMEOUT = 'session/redis/timeout';
47 
51  const PARAM_PERSISTENT_IDENTIFIER = 'session/redis/persistent_identifier';
52 
56  const PARAM_COMPRESSION_THRESHOLD = 'session/redis/compression_threshold';
57 
61  const PARAM_COMPRESSION_LIBRARY = 'session/redis/compression_library';
62 
66  const PARAM_MAX_CONCURRENCY = 'session/redis/max_concurrency';
67 
71  const PARAM_MAX_LIFETIME = 'session/redis/max_lifetime';
72 
76  const PARAM_MIN_LIFETIME = 'session/redis/min_lifetime';
77 
81  const PARAM_DISABLE_LOCKING = 'session/redis/disable_locking';
82 
86  const PARAM_BOT_LIFETIME = 'session/redis/bot_lifetime';
87 
91  const PARAM_BOT_FIRST_LIFETIME = 'session/redis/bot_first_lifetime';
92 
96  const PARAM_FIRST_LIFETIME = 'session/redis/first_lifetime';
97 
101  const PARAM_BREAK_AFTER = 'session/redis/break_after';
102 
106  const PARAM_SENTINEL_SERVERS = 'session/redis/sentinel_servers';
107 
111  const PARAM_SENTINEL_MASTER = 'session/redis/sentinel_master';
112 
116  const PARAM_SENTINEL_VERIFY_MASTER = 'session/redis/sentinel_verify_master';
117 
121  const PARAM_SENTINEL_CONNECT_RETRIES = 'session/redis/sentinel_connect_retries';
122 
126  const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
127 
131  const XML_PATH_ADMIN_SESSION_LIFETIME = 'admin/security/session_lifetime';
132 
136  const SESSION_MAX_LIFETIME = 31536000;
137 
141  const DEFAULT_FAIL_AFTER = 15;
142 
148  private $deploymentConfig;
149 
153  private $scopeConfig;
154 
158  private $appState;
159 
165  public function __construct(
166  DeploymentConfig $deploymentConfig,
167  State $appState,
168  ScopeConfigInterface $scopeConfig
169  ) {
170  $this->deploymentConfig = $deploymentConfig;
171  $this->appState = $appState;
172  $this->scopeConfig = $scopeConfig;
173  }
174 
178  public function getLogLevel()
179  {
180  return $this->deploymentConfig->get(self::PARAM_LOG_LEVEL);
181  }
182 
186  public function getHost()
187  {
188  return $this->deploymentConfig->get(self::PARAM_HOST);
189  }
190 
194  public function getPort()
195  {
196  return $this->deploymentConfig->get(self::PARAM_PORT);
197  }
198 
202  public function getDatabase()
203  {
204  return $this->deploymentConfig->get(self::PARAM_DATABASE);
205  }
206 
210  public function getPassword()
211  {
212  return $this->deploymentConfig->get(self::PARAM_PASSWORD);
213  }
214 
218  public function getTimeout()
219  {
220  return $this->deploymentConfig->get(self::PARAM_TIMEOUT);
221  }
222 
226  public function getPersistentIdentifier()
227  {
228  return $this->deploymentConfig->get(self::PARAM_PERSISTENT_IDENTIFIER);
229  }
230 
234  public function getCompressionThreshold()
235  {
236  return $this->deploymentConfig->get(self::PARAM_COMPRESSION_THRESHOLD);
237  }
238 
242  public function getCompressionLibrary()
243  {
244  return $this->deploymentConfig->get(self::PARAM_COMPRESSION_LIBRARY);
245  }
246 
250  public function getMaxConcurrency()
251  {
252  return $this->deploymentConfig->get(self::PARAM_MAX_CONCURRENCY);
253  }
254 
258  public function getMaxLifetime()
259  {
261  }
262 
266  public function getMinLifetime()
267  {
268  return $this->deploymentConfig->get(self::PARAM_MIN_LIFETIME);
269  }
270 
274  public function getDisableLocking()
275  {
276  return $this->deploymentConfig->get(self::PARAM_DISABLE_LOCKING);
277  }
278 
282  public function getBotLifetime()
283  {
284  return $this->deploymentConfig->get(self::PARAM_BOT_LIFETIME);
285  }
286 
290  public function getBotFirstLifetime()
291  {
292  return $this->deploymentConfig->get(self::PARAM_BOT_FIRST_LIFETIME);
293  }
294 
298  public function getFirstLifetime()
299  {
300  return $this->deploymentConfig->get(self::PARAM_FIRST_LIFETIME);
301  }
302 
306  public function getBreakAfter()
307  {
308  return $this->deploymentConfig->get(self::PARAM_BREAK_AFTER . '_' . $this->appState->getAreaCode());
309  }
310 
314  public function getLifetime()
315  {
316  if ($this->appState->getAreaCode() == \Magento\Framework\App\Area::AREA_ADMINHTML) {
317  return (int)$this->scopeConfig->getValue(self::XML_PATH_ADMIN_SESSION_LIFETIME);
318  }
319  return (int)$this->scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, StoreScopeInterface::SCOPE_STORE);
320  }
321 
325  public function getSentinelServers()
326  {
327  return $this->deploymentConfig->get(self::PARAM_SENTINEL_SERVERS);
328  }
329 
333  public function getSentinelMaster()
334  {
335  return $this->deploymentConfig->get(self::PARAM_SENTINEL_MASTER);
336  }
337 
341  public function getSentinelVerifyMaster()
342  {
343  return $this->deploymentConfig->get(self::PARAM_SENTINEL_VERIFY_MASTER);
344  }
345 
349  public function getSentinelConnectRetries()
350  {
351  return $this->deploymentConfig->get(self::PARAM_SENTINEL_CONNECT_RETRIES);
352  }
353 
357  public function getFailAfter()
358  {
360  }
361 }
$deploymentConfig
__construct(DeploymentConfig $deploymentConfig, State $appState, ScopeConfigInterface $scopeConfig)
Definition: Config.php:165