Sulu\Bundle\MediaBundle\Controller\MediaStreamController::downloadAction PHP Метод

downloadAction() публичный Метод

public downloadAction ( Request $request, integer $id ) : BinaryFileResponse
$request Symfony\Component\HttpFoundation\Request
$id integer
Результат Symfony\Component\HttpFoundation\BinaryFileResponse
    public function downloadAction(Request $request, $id)
    {
        try {
            if (ob_get_length()) {
                ob_end_clean();
            }
            $version = $request->get('v', null);
            $noCount = $request->get('no-count', false);
            $fileVersion = $this->getFileVersion($id, $version);
            if (!$fileVersion) {
                return new Response(null, 404);
            }
            $dispositionType = ResponseHeaderBag::DISPOSITION_ATTACHMENT;
            if ($request->get('inline', false)) {
                $dispositionType = ResponseHeaderBag::DISPOSITION_INLINE;
            }
            if (!$noCount) {
                $this->getMediaManager()->increaseDownloadCounter($fileVersion->getId());
            }
            $response = $this->getFileResponse($fileVersion, $request->getLocale(), $dispositionType);
            return $response;
        } catch (MediaException $e) {
            throw $this->createNotFoundException('File not found: ' . $e->getCode() . ' ' . $e->getMessage());
        }
    }