Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
AppsController
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 appIcon
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace Olz\Controller;
4
5use Olz\Apps\OlzApps;
6use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7use Symfony\Component\HttpFoundation\BinaryFileResponse;
8use Symfony\Component\HttpFoundation\Response;
9use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
10use Symfony\Component\Routing\Annotation\Route;
11
12class AppsController extends AbstractController {
13    #[Route('/apps/{app_basename}/icon.svg', requirements: ['app_basename' => '[a-zA-Z0-9_-]+'])]
14    public function appIcon(
15        string $app_basename,
16    ): Response {
17        $app = OlzApps::getApp($app_basename);
18        $path = $app?->getIconPath();
19        if ($path === null) {
20            throw new NotFoundHttpException();
21        }
22        return new BinaryFileResponse($path);
23    }
24}