Conditions | 8 |
Paths | 111 |
Total Lines | 31 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function process($data, Operation $operation, array $uriVariables = [], array $context = []): void |
||
23 | { |
||
24 | if (!$data instanceof CStudentPublication) { |
||
25 | return; |
||
26 | } |
||
27 | |||
28 | $node = $data->hasResourceNode() ? $data->getResourceNode() : null; |
||
29 | |||
30 | $this->em->beginTransaction(); |
||
31 | try { |
||
32 | try { $this->em->refresh($data); } catch (\Throwable) {} |
||
|
|||
33 | |||
34 | $this->em->remove($data); |
||
35 | $this->em->flush(); |
||
36 | |||
37 | if ($node instanceof ResourceNode) { |
||
38 | foreach ($node->getResourceLinks() as $link) { |
||
39 | $this->em->remove($link); |
||
40 | } |
||
41 | $this->em->flush(); |
||
42 | |||
43 | foreach ($node->getResourceFiles() as $file) { |
||
44 | $this->em->remove($file); |
||
45 | } |
||
46 | $this->em->flush(); |
||
47 | } |
||
48 | |||
49 | $this->em->commit(); |
||
50 | } catch (\Throwable $e) { |
||
51 | $this->em->rollback(); |
||
52 | throw $e; |
||
53 | } |
||
56 |