Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 | $metadata = $manager->getClassMetadata($class); |
||
35 | |||
36 | foreach ($data as $property => &$value) { |
||
37 | if ($metadata->hasAssociation($property)) { |
||
38 | $assoc = $metadata->getAssociationTargetClass($property); |
||
39 | |||
40 | if ($manager instanceof EntityManagerInterface) { |
||
41 | $value = $manager->getReference($assoc, $value); |
||
42 | } else { |
||
43 | $value = $manager->find($assoc, $value); |
||
44 | } |
||
45 | } |
||
46 | } |
||
47 | |||
48 | return $this->processor->updateEntity($entity, $data); |
||
49 | } |
||
50 | } |
||
51 |