/**
* Used by the REST API to reference downloadable files.
* It redirects (permanently) to the standard ez_content_download route, based on the language of the field
* passed as an argument, using the language switcher.
*
* @param mixed $contentId
* @param int $fieldId
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function redirectToContentDownloadAction($contentId, $fieldId, Request $request)
{
$content = $this->contentService->loadContent($contentId);
$field = $this->findFieldInContent($fieldId, $content);
$params = array('content' => $content, 'fieldIdentifier' => $field->fieldDefIdentifier, 'language' => $field->languageCode);
if ($request->query->has('version')) {
$params['version'] = $request->query->get('version');
}
$downloadUrl = $this->router->generate($this->routeReferenceGenerator->generate('ez_content_download', $params));
return new RedirectResponse($downloadUrl, 301);
}