Passed
Push — master ( 2d5267...ac6adc )
by Yannick
16:02 queued 05:48
created

PwaController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
dl 0
loc 40
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A manifest() 0 38 3
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 Chamilo\CoreBundle\Helpers\ThemeHelper;
10
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\Routing\Annotation\Route;
13
14
class PwaController extends AbstractController
15
{
16
    #[Route('/manifest.json', name: 'pwa_manifest')]
17
    public function manifest(ThemeHelper $themeHelper): Response
18
    {
19
        $theme = $themeHelper->getVisualTheme();
20
21
        $icon192 = $themeHelper->getThemeAssetUrl('images/pwa-icons/icon-192.png');
22
        $icon512 = $themeHelper->getThemeAssetUrl('images/pwa-icons/icon-512.png');
23
24
        $icons = [];
25
26
        if (!empty($icon192)) {
27
            $icons[] = [
28
                'src' => $icon192,
29
                'sizes' => '192x192',
30
                'type' => 'image/png',
31
            ];
32
        }
33
34
        if (!empty($icon512)) {
35
            $icons[] = [
36
                'src' => $icon512,
37
                'sizes' => '512x512',
38
                'type' => 'image/png',
39
            ];
40
        }
41
42
        $data = [
43
            'name' => 'Chamilo LMS',
44
            'short_name' => 'Chamilo',
45
            'start_url' => '/',
46
            'display' => 'standalone',
47
            'theme_color' => '#1b4fa0',
48
            'background_color' => '#ffffff',
49
            'orientation' => 'portrait-primary',
50
            'icons' => $icons,
51
        ];
52
53
        return $this->json($data);
54
    }
55
}
56