/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/View/Element/Js/Cookie.php
89 строк
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\View\Element\Js; use Magento\Framework\Session\Config\ConfigInterface; use Magento\Framework\View\Element\Template; use Magento\Framework\View\Element\Template\Context; /** * Block passes configuration for cookies set by JS * * @api * @since 100.0.2 */ class Cookie extends Template { /** * Session config * * @var ConfigInterface */ protected $sessionConfig; /** * @var \Magento\Framework\Validator\Ip */ protected $ipValidator; /** * Constructor * * @param Context $context * @param ConfigInterface $cookieConfig * @param \Magento\Framework\Validator\Ip $ipValidator * @param array $data */ public function __construct( Context $context, ConfigInterface $cookieConfig, \Magento\Framework\Validator\Ip $ipValidator, array $data = [] ) { $this->sessionConfig = $cookieConfig; $this->ipValidator = $ipValidator; parent::__construct($context, $data); } /** * Get configured cookie domain * * @return string */ public function getDomain() { $domain = $this->sessionConfig->getCookieDomain(); if ($this->ipValidator->isValid($domain)) { return $domain; } if (!empty($domain[0]) && $domain[0] !== '.') { $domain = '.' . $domain; } return $domain; } /** * Get configured cookie path * * @return string */ public function getPath() { return $this->sessionConfig->getCookiePath(); } /** * Get configured cookie lifetime * * @return int */ public function getLifetime() { return $this->sessionConfig->getCookieLifetime(); } }