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

GetSettingsController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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