Issues (279)

api/src/Fixture/User.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace App\Fixture;
4
5
use App\EventListener\Entity\User\IdentityListener;
6
use Doctrine\Common\Persistence\ObjectManager;
0 ignored issues
show
The type Doctrine\Common\Persistence\ObjectManager was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Ds\Component\Database\Fixture\Yaml;
0 ignored issues
show
The type Ds\Component\Database\Fixture\Yaml was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Trait User
11
 */
12
trait User
13
{
14
    use Yaml;
15
16
    /**
17
     * @var string
18
     */
19
    private $path;
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load(ObjectManager $manager)
25
    {
26
        $eventManager = $manager->getEventManager();
27
28
        foreach ($eventManager->getListeners() as $event => $listeners) {
29
            foreach ($listeners as $key => $listener) {
30
                if (is_object($listener) && $listener instanceof IdentityListener) {
31
                    $listener->setEnabled(false);
32
                } else if (is_string($listener) && $listener === IdentityListener::class) {
33
                    $eventManager->removeEventListener(['postPersist'], $listener);
34
                }
35
            }
36
        }
37
38
        $userManager = $this->container->get('fos_user.user_manager');
39
        $objects = $this->parse($this->path);
40
41
        foreach ($objects as $object) {
42
            $user = $userManager->createUser();
43
            $user
44
                ->setUuid($object->uuid)
45
                ->setUsername($object->username)
46
                ->setEmail($object->email)
47
                ->setPlainPassword($object->password)
48
                ->setRoles($object->roles)
49
                ->setOwner($object->owner)
50
                ->setOwnerUuid($object->owner_uuid)
51
                ->setIdentity($object->identity)
52
                ->setIdentityUuid($object->identity_uuid)
53
                ->setEnabled($object->enabled)
54
                ->setTenant($object->tenant);
55
            $userManager->updateUser($user);
56
        }
57
    }
58
}
59