private function getCacheKey(Request $request)
{
$user = $request->getUser();
$imageIdentifier = $request->getImageIdentifier();
$accept = $request->headers->get('Accept', '*/*');
$accept = array_filter(explode(',', $accept), function (&$value) {
// Trim whitespace
$value = trim($value);
// Remove optional params
$pos = strpos($value, ';');
if ($pos !== false) {
$value = substr($value, 0, $pos);
}
// Keep values starting with "*/" or "image/"
return $value[0] === '*' && $value[1] === '/' || substr($value, 0, 6) === 'image/';
});
// Sort the remaining values
sort($accept);
$accept = implode(',', $accept);
$extension = $request->getExtension();
$transformations = $request->query->get('t');
if (!empty($transformations)) {
$transformations = implode('&', $transformations);
}
return md5($user . $imageIdentifier . $accept . $extension . $transformations);
}