<commit_before><?php

namespace MediaMonks\SonataMediaBundle\Controller;

use Doctrine\Persistence\ManagerRegistry;
use League\Glide\Filesystem\FilesystemException;
use MediaMonks\SonataMediaBundle\Model\MediaInterface;
use MediaMonks\SonataMediaBundle\ParameterBag\ImageParameterBag;
use MediaMonks\SonataMediaBundle\ParameterBag\MediaParameterBag;
use MediaMonks\SonataMediaBundle\Service\ImageResponseHandler;
use MediaMonks\SonataMediaBundle\Service\MediaResponseHandler;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;

class MediaController
{
    private ManagerRegistry $registry;
    private MediaResponseHandler $mediaResponseHandler;
    private ImageResponseHandler $imageResponseHandler;
    private string $mediaEntityClass;

    public function __construct(
        ManagerRegistry $registry,
        MediaResponseHandler $mediaResponseHandler,
        ImageResponseHandler $imageResponseHandler,
        string $mediaEntityClass
    )
    {
        $this->registry = $registry;
        $this->mediaResponseHandler = $mediaResponseHandler;
        $this->imageResponseHandler = $imageResponseHandler;
        $this->mediaEntityClass = $mediaEntityClass;
    }

    /**
     * @param Request $request
     * @param int $id
     *
     * @return StreamedResponse
     */
    public function streamAction(
        Request $request,
        int $id
    ): StreamedResponse
    {
        return $this->mediaResponseHandler->getStreamedResponse(
            $this->getMediaById($id),
            new MediaParameterBag($request->query->all())
        );
    }

    /**
     * @param Request $request
     * @param int $id
     *
     * @return StreamedResponse
     */
    public function downloadAction(
        Request $request,
        int $id
    ): StreamedResponse
    {
        return $this->mediaResponseHandler->getStreamedResponse(
            $this->getMediaById($id),
            new MediaParameterBag($request->query->all())
        );
    }<commit_msg>Fix download route bug<commit_after><?php

namespace MediaMonks\SonataMediaBundle\Controller;

use Doctrine\Persistence\ManagerRegistry;
use League\Glide\Filesystem\FilesystemException;
use MediaMonks\SonataMediaBundle\Model\MediaInterface;
use MediaMonks\SonataMediaBundle\ParameterBag\ImageParameterBag;
use MediaMonks\SonataMediaBundle\ParameterBag\MediaParameterBag;
use MediaMonks\SonataMediaBundle\Service\ImageResponseHandler;
use MediaMonks\SonataMediaBundle\Service\MediaResponseHandler;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;

class MediaController
{
    private ManagerRegistry $registry;
    private MediaResponseHandler $mediaResponseHandler;
    private ImageResponseHandler $imageResponseHandler;
    private string $mediaEntityClass;

    public function __construct(
        ManagerRegistry $registry,
        MediaResponseHandler $mediaResponseHandler,
        ImageResponseHandler $imageResponseHandler,
        string $mediaEntityClass
    )
    {
        $this->registry = $registry;
        $this->mediaResponseHandler = $mediaResponseHandler;
        $this->imageResponseHandler = $imageResponseHandler;
        $this->mediaEntityClass = $mediaEntityClass;
    }

    /**
     * @param Request $request
     * @param int $id
     *
     * @return StreamedResponse
     */
    public function streamAction(
        Request $request,
        int $id
    ): StreamedResponse
    {
        return $this->mediaResponseHandler->getStreamedResponse(
            $this->getMediaById($id),
            new MediaParameterBag($request->query->all())
        );
    }

    /**
     * @param Request $request
     * @param int $id
     *
     * @return StreamedResponse
     */
    public function downloadAction(
        Request $request,
        int $id
    ): StreamedResponse
    {
        return $this->mediaResponseHandler->getDownloadResponse(
            $this->getMediaById($id),
            new MediaParameterBag($request->query->all())
        );
    }
{'fraction_non_alphanumeric': 0.0877487413090386, 'fraction_numerical': 0.0, 'mean_word_length': 3.345833333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '346202', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1067, 'n_words': 199}