本文整理匯總了PHP中Symfony\Component\HttpFoundation\HeaderBag::replace方法的典型用法代碼示例。如果您正苦於以下問題:PHP HeaderBag::replace方法的具體用法?PHP HeaderBag::replace怎麽用?PHP HeaderBag::replace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpFoundation\HeaderBag
的用法示例。
在下文中一共展示了HeaderBag::replace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testReplace
/**
* @covers Symfony\Component\HttpFoundation\HeaderBag::replace
*/
public function testReplace()
{
$bag = new HeaderBag(array('foo' => 'bar'));
$bag->replace(array('NOPE' => 'BAR'));
$this->assertEquals(array('nope' => array('BAR')), $bag->all(), '->replace() replaces the input with the argument');
$this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input');
}
示例2: testCacheControlDirectiveOverrideWithReplace
public function testCacheControlDirectiveOverrideWithReplace()
{
$bag = new HeaderBag(array('cache-control' => 'private, max-age=100'));
$bag->replace(array('cache-control' => 'public, max-age=10'));
$this->assertTrue($bag->hasCacheControlDirective('public'));
$this->assertTrue($bag->getCacheControlDirective('public'));
$this->assertTrue($bag->hasCacheControlDirective('max-age'));
$this->assertEquals(10, $bag->getCacheControlDirective('max-age'));
}
示例3: replace
/**
* {@inheritdoc}
*
* @api
*/
public function replace(array $headers = array())
{
$this->headerNames = array();
parent::replace($headers);
}