Conditions | 6 |
Paths | 2 |
Total Lines | 28 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function updateEntity($entity, $data) |
||
30 | { |
||
31 | $class = get_class($entity); |
||
32 | |||
33 | $manager = $this->registry->getManagerForClass($class); |
||
34 | |||
35 | if (null !== $manager) { |
||
36 | $metadata = $manager->getClassMetadata($class); |
||
37 | |||
38 | foreach ($data as $property => &$value) { |
||
39 | if (null === $value) { |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | if ($metadata->hasAssociation($property)) { |
||
44 | $assoc = $metadata->getAssociationTargetClass($property); |
||
45 | |||
46 | if ($manager instanceof EntityManagerInterface) { |
||
47 | $value = $manager->getReference($assoc, $value); |
||
48 | } else { |
||
49 | $value = $manager->find($assoc, $value); |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | |||
55 | return $this->processor->updateEntity($entity, $data); |
||
56 | } |
||
57 | } |
||
58 |