Imbo\EventListener\ImageTransformationCache::getCacheKey PHP Method

getCacheKey() private method

Generate a cache key
private getCacheKey ( Request $request ) : string
$request Imbo\Http\Request\Request The current request instance
return string Returns a string that can be used as a cache key for the current image
    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);
    }