Commit b699674f authored by Niklas de Vries's avatar Niklas de Vries

Merge branch 'feature/add-mp3' into 'master'

added mp3 support

See merge request !6
parents 311fa397 e7e7e80b
<?php
/*
* This file is part of CwdMediaBundle
*
* (c)2016 Ludwig Ruderstaller <lr@cwd.at>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cwd\MediaBundle\Controller;
use Cwd\MediaBundle\Model\Entity\Media;
use Cwd\MediaBundle\Service\MediaService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
/**
* Class MediaController
*
* @package Cwd\MediaBundle\Controller
* @author Ludwig Ruderstaller <lr@cwd.at>
*
* @PreAuthorize("hasRole('ROLE_ADMIN')")
* @Route("/media")
*/
class MediaController extends Controller
{
/**
* @param Media $media
* @Route("/file/{media}")
* @ParamConverter("media", class="Model:Media", options={"mapping": {"media" = "id"}})
* @return BinaryFileResponse
*/
public function fileAction(Media $media)
{
return new BinaryFileResponse($this->get('cwd.media.service')->getFilePath($media));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment