Conditions | 2 |
Paths | 2 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function load(Tenant $tenant) |
||
34 | { |
||
35 | $yml = file_get_contents('/srv/api-platform/src/AppBundle/Resources/tenant/identity/system/identities.yml'); |
||
36 | |||
37 | // @todo Figure out how symfony does parameter binding and use the same technique |
||
38 | $yml = strtr($yml, [ |
||
39 | '%identity.system.uuid%' => $tenant->getData()['identity']['system']['uuid'], |
||
40 | '%tenant.uuid%' => $tenant->getUuid() |
||
41 | ]); |
||
42 | |||
43 | $systems = Yaml::parse($yml, YAML::PARSE_OBJECT_FOR_MAP); |
||
44 | $manager = $this->systemService->getManager(); |
||
45 | |||
46 | foreach ($systems->objects as $object) { |
||
47 | $object = (object) array_merge((array) $systems->prototype, (array) $object); |
||
48 | $system = $this->systemService->createInstance(); |
||
49 | $system |
||
50 | ->setUuid($object->uuid) |
||
51 | ->setOwner($object->owner) |
||
52 | ->setOwnerUuid($object->owner_uuid) |
||
53 | ->setTenant($object->tenant); |
||
54 | $manager->persist($system); |
||
55 | $manager->flush(); |
||
56 | } |
||
59 |