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

GetEditUserController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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