public function purgeByRequest(Request $request)
{
if (!$request->headers->has('X-Location-Id') && !$request->headers->has('X-Group-Location-Id')) {
return $this->purge($request->getUri());
}
// Purge everything
$locationId = $request->headers->get('X-Location-Id');
if ($locationId === '*' || $locationId === '.*') {
return $this->purgeAllContent();
}
// Usage of X-Group-Location-Id is deprecated.
if ($request->headers->has('X-Group-Location-Id')) {
$aLocationId = explode('; ', $request->headers->get('X-Group-Location-Id'));
} elseif ($locationId[0] === '(' && substr($locationId, -1) === ')') {
// Equivalent to X-Group-Location-Id, using a simple Regexp:
// (123|456|789) => Purge for #123, #456 and #789 location IDs.
$aLocationId = explode('|', substr($locationId, 1, -1));
} else {
$aLocationId = array($locationId);
}
if (empty($aLocationId)) {
return false;
}
foreach ($aLocationId as $locationId) {
$this->purgeLocation($locationId);
}
return true;
}