public function handle($request)
{
// Validate the signing token
if (($token = $this->url->signingToken($request)) && $token != $this->request->input('token')) {
throw new NotFoundHttpException('Token mismatch');
}
// Create the image file
$crop_path = $this->render($request);
// Redirect to remote crops ...
if ($this->storage->cropsAreRemote()) {
return new RedirectResponse($this->url->pathToUrl($crop_path), 301);
// ... or echo the image data to the browser
} else {
$absolute_path = $this->storage->getLocalCropsDirPath() . '/' . $crop_path;
return new BinaryFileResponse($absolute_path, 200, ['Content-Type' => $this->getContentType($absolute_path)]);
}
}