本文整理匯總了PHP中Magento\Framework\App\Http\Context::getVaryString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Context::getVaryString方法的具體用法?PHP Context::getVaryString怎麽用?PHP Context::getVaryString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\App\Http\Context
的用法示例。
在下文中一共展示了Context::getVaryString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetVaryString
public function testGetVaryString()
{
$this->object->setValue('key2', 'value2', 'default2');
$this->object->setValue('key1', 'value1', 'default1');
$data = ['key2' => 'value2', 'key1' => 'value1'];
ksort($data);
$this->assertEquals(sha1(serialize($data)), $this->object->getVaryString());
}
示例2: sendVary
/**
* Send Vary cookie
*
* @return void
*/
public function sendVary()
{
$varyString = $this->context->getVaryString();
if ($varyString) {
$sensitiveCookMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata()->setPath('/');
$this->cookieManager->setSensitiveCookie(self::COOKIE_VARY_STRING, $varyString, $sensitiveCookMetadata);
} elseif ($this->request->get(self::COOKIE_VARY_STRING)) {
$cookieMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata()->setPath('/');
$this->cookieManager->deleteCookie(self::COOKIE_VARY_STRING, $cookieMetadata);
}
}
示例3: getValue
/**
* Return unique page identifier
*
* @return string
*/
public function getValue()
{
$data = [$this->request->getUriString(), $this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING) ?: $this->context->getVaryString()];
return md5(serialize($data));
}