Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| AppsController | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| appIcon | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Controller; |
| 4 | |
| 5 | use Olz\Apps\OlzApps; |
| 6 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 7 | use Symfony\Component\HttpFoundation\BinaryFileResponse; |
| 8 | use Symfony\Component\HttpFoundation\Response; |
| 9 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
| 10 | use Symfony\Component\Routing\Annotation\Route; |
| 11 | |
| 12 | class 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 | } |