Passed
Push — develop ( 0d66a7...37c69c )
by Laurent
05:34 queued 02:39
created

GetSettingsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Administration\Infrastructure\Settings\Controller;
15
16
use Administration\Infrastructure\Settings\Query\GetSettings;
17
use Core\Infrastructure\Common\MessengerQueryBus;
18
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
19
use Symfony\Component\HttpFoundation\RedirectResponse;
20
use Symfony\Component\HttpFoundation\Response;
21
22
class GetSettingsController extends AbstractController
23
{
24
    private MessengerQueryBus $queryBus;
25
26
    public function __construct(MessengerQueryBus $queryBus)
27
    {
28
        $this->queryBus = $queryBus;
29
    }
30
31
    public function __invoke(): Response
32
    {
33
        $query = new GetSettings();
34
        $settings = $this->queryBus->handle($query);
35
36
        if (null === $settings) {
37
            return new RedirectResponse($this->generateUrl('admin_settings_new'));
38
        }
39
40
        return $this->render('Administration/Settings/index.html.twig', [
41
            'settings' => $settings,
42
        ]);
43
    }
44
}
45