mirror of
https://github.com/quentin-g-dev/afup.git
synced 2026-03-26 10:12:16 +01:00
30 lines
794 B
PHP
30 lines
794 B
PHP
<?php
|
|
|
|
namespace AppBundle\Controller\Website;
|
|
|
|
use AppBundle\Event\Model\Repository\BadgeRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
|
|
class BadgeController extends Controller
|
|
{
|
|
public function badgeAction($id)
|
|
{
|
|
$badge = $this->get('ting')->get(BadgeRepository::class)->get($id);
|
|
|
|
if (null === $badge) {
|
|
throw $this->createNotFoundException();
|
|
}
|
|
|
|
$dir = $this->getParameter('kernel.project_dir') . '/htdocs/uploads/badges';
|
|
|
|
$filepath = $dir . DIRECTORY_SEPARATOR . $badge->getUrl();
|
|
|
|
if (false === is_file($filepath)) {
|
|
throw $this->createNotFoundException();
|
|
}
|
|
|
|
return new BinaryFileResponse($filepath);
|
|
}
|
|
}
|