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