Skip to content

Commit 7dea240

Browse files
committed
Merge pull request #119 from usemarkup/master
Add headers as optional argument to CacheInvalidator
2 parents 80f145c + 879db5e commit 7dea240

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/CacheInvalidator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,20 @@ public function getTagsHeader()
166166
/**
167167
* Invalidate a path or URL
168168
*
169-
* @param string $path Path or URL
169+
* @param string $path Path or URL
170+
* @param array $headers HTTP headers (optional)
170171
*
171172
* @throws UnsupportedProxyOperationException
172173
*
173174
* @return $this
174175
*/
175-
public function invalidatePath($path)
176+
public function invalidatePath($path, array $headers = array())
176177
{
177178
if (!$this->cache instanceof PurgeInterface) {
178179
throw UnsupportedProxyOperationException::cacheDoesNotImplement('PURGE');
179180
}
180181

181-
$this->cache->purge($path);
182+
$this->cache->purge($path, $headers);
182183

183184
return $this;
184185
}

tests/Unit/CacheInvalidatorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ public function testSupportsInvalid()
6060
public function testInvalidatePath()
6161
{
6262
$purge = \Mockery::mock('\FOS\HttpCache\ProxyClient\Invalidation\PurgeInterface')
63-
->shouldReceive('purge')->once()->with('/my/route')
63+
->shouldReceive('purge')->once()->with('/my/route', array())
64+
->shouldReceive('purge')->once()->with('/my/route', array('X-Test-Header' => 'xyz'))
6465
->shouldReceive('flush')->once()
6566
->getMock();
6667

6768
$cacheInvalidator = new CacheInvalidator($purge);
6869

6970
$cacheInvalidator
7071
->invalidatePath('/my/route')
72+
->invalidatePath('/my/route', array('X-Test-Header' => 'xyz'))
7173
->flush()
7274
;
7375
}

0 commit comments

Comments
 (0)