eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::purge PHP Method

purge() public method

Triggers the cache purge $locationIds.
public purge ( mixed $locationIds )
$locationIds mixed Cache resource(s) to purge (e.g. array of URI to purge in a reverse proxy)
    public function purge($locationIds)
    {
        if (empty($locationIds)) {
            return;
        }
        if (!is_array($locationIds)) {
            $locationIds = array($locationIds);
        }
        $purgeRequest = Request::create('http://localhost/', 'BAN');
        $purgeRequest->headers->set('X-Location-Id', '(' . implode('|', $locationIds) . ')');
        $this->cacheStore->purgeByRequest($purgeRequest);
    }

Usage Example

 /**
  * @covers eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::__construct
  * @covers eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::purge
  */
 public function testPurge()
 {
     $cacheStore = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Cache\\Http\\ContentPurger');
     $cacheStore->expects($this->once())->method('purgeByRequest')->with($this->isInstanceOf('Symfony\\Component\\HttpFoundation\\Request'));
     $purgeClient = new LocalPurgeClient($cacheStore);
     $purgeClient->purge(array(123, 456, 789));
 }
All Usage Examples Of eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::purge