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