Passed
Push — develop ( 370f48...cc396d )
by Laurent
07:33 queued 04:53
created

GetEditUserController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 1
A __construct() 0 3 1
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\User\Controller;
15
16
use Administration\Infrastructure\Finders\DoctrineOrm\DoctrineUserFinder;
17
use Administration\Infrastructure\User\Form\UserType;
18
use Doctrine\ORM\NonUniqueResultException;
19
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
20
use Symfony\Component\HttpFoundation\Response;
21
22
class GetEditUserController extends AbstractController
23
{
24
    private DoctrineUserFinder $finder;
25
26
    public function __construct(DoctrineUserFinder $finder)
27
    {
28
        $this->finder = $finder;
29
    }
30
31
    /**
32
     * @throws NonUniqueResultException
33
     */
34
    public function __invoke(string $uuid): Response
35
    {
36
        $user = $this->finder->findOneByUuid($uuid);
37
        $form = $this->createForm(UserType::class, $user, [
38
            'action' => $this->generateUrl('admin_user_update', ['uuid' => $uuid]),
39
            'method' => 'PUT',
40
        ]);
41
42
        return $this->render('Administration/User/edit.html.twig', [
43
            'form' => $form->createView(),
44
        ]);
45
    }
46
}
47