mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 17:27:36 +00:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Magento\Persistent\Model\Plugin;
|
|
|
|
/**
|
|
* Plugin for Magento\Framework\App\Http\Context to create new page cache variation for persistent session.
|
|
*/
|
|
class PersistentCustomerContext
|
|
{
|
|
/**
|
|
* Persistent session.
|
|
*
|
|
* @var \Magento\Persistent\Helper\Session
|
|
*/
|
|
private $persistentSession;
|
|
|
|
/**
|
|
* @param \Magento\Persistent\Helper\Session $persistentSession
|
|
*/
|
|
public function __construct(
|
|
\Magento\Persistent\Helper\Session $persistentSession
|
|
) {
|
|
$this->persistentSession = $persistentSession;
|
|
}
|
|
|
|
/**
|
|
* Sets appropriate header if customer session is persistent.
|
|
*
|
|
* @param \Magento\Framework\App\Http\Context $subject
|
|
* @return mixed
|
|
*/
|
|
public function beforeGetVaryString(\Magento\Framework\App\Http\Context $subject)
|
|
{
|
|
if ($this->persistentSession->isPersistent()) {
|
|
$subject->setValue('PERSISTENT', 1, 0);
|
|
}
|
|
}
|
|
}
|