Symfony\Component\HttpFoundation\ResponseHeaderBag::replace PHP Method

replace() public method

public replace ( array $headers = [] )
$headers array
    public function replace(array $headers = array())
    {
        $this->headerNames = array();

        parent::replace($headers);

        if (!isset($this->headers['cache-control'])) {
            $this->set('Cache-Control', '');
        }
    }

Usage Example

 public function testReplaceWithRemove()
 {
     $bag = new ResponseHeaderBag(array());
     $this->assertEquals('no-cache', $bag->get('Cache-Control'));
     $this->assertTrue($bag->hasCacheControlDirective('no-cache'));
     $bag->remove('Cache-Control');
     $bag->replace(array());
     $this->assertEquals('no-cache', $bag->get('Cache-Control'));
     $this->assertTrue($bag->hasCacheControlDirective('no-cache'));
 }