1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Tenant\Loader; |
4
|
|
|
|
5
|
|
|
use App\EventListener\Entity\User\IdentityListener; |
6
|
|
|
use Ds\Component\Database\Util\Objects; |
|
|
|
|
7
|
|
|
use Ds\Component\Tenant\Entity\Tenant; |
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Trait User |
11
|
|
|
*/ |
12
|
|
|
trait User |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var \App\Service\UserService |
16
|
|
|
*/ |
17
|
|
|
private $userService; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $path; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function load(Tenant $tenant) |
28
|
|
|
{ |
29
|
|
|
$eventManager = $this->userService->getManager()->getEventManager(); |
30
|
|
|
|
31
|
|
|
foreach ($eventManager->getListeners() as $event => $listeners) { |
32
|
|
|
foreach ($listeners as $key => $listener) { |
33
|
|
|
if (is_object($listener) && $listener instanceof IdentityListener) { |
34
|
|
|
$listener->setEnabled(false); |
35
|
|
|
} else if (is_string($listener) && $listener === IdentityListener::class) { |
36
|
|
|
$eventManager->removeEventListener(['postPersist'], $listener); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$data = (array) json_decode(json_encode($tenant->getData())); |
42
|
|
|
$objects = Objects::parseFile($this->path, $data); |
43
|
|
|
$manager = $this->userService->getCustomManager(); |
44
|
|
|
|
45
|
|
|
foreach ($objects as $object) { |
46
|
|
|
$user = $manager->createUser(); |
47
|
|
|
$user |
48
|
|
|
->setUsername($object->username) |
49
|
|
|
->setEmail($object->email) |
50
|
|
|
->setPlainPassword($object->password) |
51
|
|
|
->setRoles($object->roles) |
52
|
|
|
->setOwner($object->owner) |
53
|
|
|
->setOwnerUuid($object->owner_uuid) |
54
|
|
|
->setIdentity($object->identity) |
55
|
|
|
->setIdentityUuid($object->identity_uuid) |
56
|
|
|
->setEnabled($object->enabled) |
57
|
|
|
->setTenant($object->tenant); |
58
|
|
|
$manager->updateUser($user); |
59
|
|
|
} |
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