Conditions | 5 |
Paths | 4 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 5.0291 |
Changes | 0 |
1 | <?php |
||
22 | 3 | public function updateAfterProcess() |
|
23 | { |
||
24 | // cleanup partial submissions |
||
25 | 3 | $request = Controller::curr()->getRequest(); |
|
26 | |||
27 | 3 | $postID = $request->postVar('PartialID'); |
|
28 | 3 | $partialID = $postID ?? $request->getSession()->get(PartialSubmissionController::SESSION_KEY); |
|
29 | 3 | if ($partialID === null) { |
|
30 | return; |
||
31 | } |
||
32 | |||
33 | /** @var PartialFormSubmission $partialForm */ |
||
34 | 3 | $partialForm = PartialFormSubmission::get()->byID($partialID); |
|
35 | 3 | if ($partialForm === null) { |
|
36 | return; |
||
37 | } |
||
38 | |||
39 | // Link files to SubmittedForm |
||
40 | 3 | $uploads = $partialForm->PartialUploads()->filter([ |
|
41 | 3 | 'UploadedFileID:not'=> 0 |
|
42 | ]); |
||
43 | 3 | if ($uploads->exists()) { |
|
44 | 3 | foreach ($uploads as $upload) { |
|
45 | 3 | $upload->ParentID = $this->owner->ID; |
|
46 | 3 | $upload->write(); |
|
47 | } |
||
48 | } |
||
49 | |||
50 | 3 | $partialForm->delete(); |
|
51 | 3 | $partialForm->destroy(); |
|
52 | 3 | $request->getSession()->clear(PartialSubmissionController::SESSION_KEY); |
|
53 | 3 | } |
|
54 | } |
||
55 |