Passed
Push — master ( 4b3edd...95e81e )
by Angel Fernando Quiroz
06:47 queued 15s
created

ThemeController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Controller;
8
9
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
11
use Symfony\Component\Filesystem\Filesystem;
12
use Symfony\Component\HttpFoundation\Response;
13
use Symfony\Component\Routing\Annotation\Route;
14
15
class ThemeController extends AbstractController
16
{
17
    public function __construct(
18
        private readonly ParameterBagInterface $parameterBag,
19
    ) {}
20
21
    #[Route('/theme/colors.css', name: 'chamilo_color_theme', methods: ['GET'])]
22
    public function colorTehemeAction(): Response
23
    {
24
        $fs = new Filesystem();
25
        $path = $this->parameterBag->get('kernel.project_dir').'/var/theme/colors.css';
26
27
        if ($fs->exists($path)) {
28
            $response = $this->file($path);
29
        } else {
30
            $response = new Response('');
31
        }
32
33
        $response->headers->add(['Content-Type' => 'text/css']);
34
35
        return $response;
36
    }
37
}
38