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 User\Infrastructure\Doctrine\DataFixtures; |
15
|
|
|
|
16
|
|
|
use Core\Domain\Common\Model\VO\EmailField; |
17
|
|
|
use Core\Domain\Common\Model\VO\NameField; |
18
|
|
|
use Core\Domain\Common\Model\VO\ResourceUuid; |
19
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture; |
|
|
|
|
20
|
|
|
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; |
|
|
|
|
21
|
|
|
use Doctrine\Persistence\ObjectManager; |
|
|
|
|
22
|
|
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; |
|
|
|
|
23
|
|
|
use User\Domain\Model\User; |
24
|
|
|
use User\Domain\Model\VO\Password; |
25
|
|
|
use User\Infrastructure\Doctrine\Entity\User as UserEntity; |
26
|
|
|
|
27
|
|
|
class UserFixtures extends Fixture implements FixtureGroupInterface |
28
|
|
|
{ |
29
|
|
|
private UserPasswordEncoderInterface $passwordEncoder; |
30
|
|
|
|
31
|
|
|
public function __construct(UserPasswordEncoderInterface $passwordEncoder) |
32
|
|
|
{ |
33
|
|
|
$this->passwordEncoder = $passwordEncoder; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function load(ObjectManager $manager): void |
37
|
|
|
{ |
38
|
|
|
$user = new User( |
39
|
|
|
ResourceUuid::fromString('a136c6fe-8f6e-45ed-91bc-586374791033'), |
40
|
|
|
NameField::fromString('Laurent'), |
41
|
|
|
EmailField::fromString('[email protected]'), |
42
|
|
|
Password::fromString('Password-1'), |
43
|
|
|
['ROLE_ADMIN'], |
44
|
|
|
); |
45
|
|
|
$userSymfony = UserEntity::fromModel($user); |
46
|
|
|
$passwordEncoded = $this->passwordEncoder->encodePassword( |
47
|
|
|
$userSymfony, |
48
|
|
|
$user->password()->value() |
49
|
|
|
); |
50
|
|
|
$user->changePassword(Password::fromString($passwordEncoded)); |
51
|
|
|
$userEntity = UserEntity::fromModel($user); |
52
|
|
|
|
53
|
|
|
$manager->persist($userEntity); |
54
|
|
|
$manager->flush(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public static function getGroups(): array |
58
|
|
|
{ |
59
|
|
|
return ['user']; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths