PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Controllers/Form/DeleteFormController.php +12 -15 0.3.1 → 1.5 View file →
@@ -1,24 +1,20 @@
1 1 <?php
2 2
3 3 /**
4 - * @copyright © TMS-Plugins. All rights reserved.
4 + * @copyright © Melograno Venture Studio. All rights reserved.
5 5 * @licence See COPYING.md for license details.
6 6 */
7 7
8 8 namespace IvyForms\Controllers\Form;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 10 use IvyForms\Common\Exceptions\ForbiddenException;
16 11 use IvyForms\Common\Exceptions\InvalidArgumentException;
17 -use IvyForms\Common\Exceptions\NotFoundException;
12 +use IvyForms\Common\Exceptions\QueryExecutionException;
18 13 use IvyForms\Common\Sanitizer\Sanitizer;
19 14 use IvyForms\Controllers\Controller;
20 15 use IvyForms\Services\Confirmation\ConfirmationService;
16 +use IvyForms\Services\Entry\EntryService;
21 17 use IvyForms\Services\Field\FieldService;
22 18 use IvyForms\Services\Form\FormService;
23 19 use IvyForms\Services\Notification\NotificationService;
24 20 use IvyForms\Services\Translations\BackendStrings;
@@ -35,19 +31,22 @@
35 31 private FormService $formService;
36 32 private FieldService $fieldService;
37 33 private NotificationService $notificationService;
38 34 private ConfirmationService $confirmationService;
35 + private EntryService $entryService;
39 36
40 37 public function __construct(
41 38 FormService $formService,
42 39 FieldService $fieldService,
43 40 NotificationService $notificationService,
44 - ConfirmationService $confirmationService
41 + ConfirmationService $confirmationService,
42 + EntryService $entryService
45 43 ) {
46 44 $this->formService = $formService;
47 45 $this->fieldService = $fieldService;
48 46 $this->notificationService = $notificationService;
49 47 $this->confirmationService = $confirmationService;
48 + $this->entryService = $entryService;
50 49 }
51 50
52 51 /**
53 52 * @param WP_REST_Request $data
@@ -53,11 +52,11 @@
53 52 * @param WP_REST_Request $data
54 53 *
55 54 * @return WP_REST_Response
56 55 *
57 - * @throws NotFoundException
58 56 * @throws InvalidArgumentException
59 57 * @throws ForbiddenException
58 + * @throws QueryExecutionException
60 59 */
61 60 public function handle(WP_REST_Request $data): WP_REST_Response
62 61 {
63 62 // Verify the nonce
@@ -72,15 +71,13 @@
72 71
73 72 // Sanitize the input data
74 73 $formId = Sanitizer::sanitizeId($data->get_param('id'));
75 74
75 + $this->entryService->getDeletionManager()->deleteEntriesByFormIds([$formId]);
76 + $this->confirmationService->deleteConfirmationsByFormIds([$formId]);
77 + $this->notificationService->deleteNotificationsByFormIds([$formId]);
78 + $this->fieldService->deleteFieldsByFormIds([$formId]);
76 79 $this->formService->deleteForm($formId);
77 -
78 - $this->fieldService->deleteFieldsByFormId($formId);
79 -
80 - $this->notificationService->deleteNotificationsByFormId($formId);
81 -
82 - $this->confirmationService->deleteConfirmationsByFormId($formId);
83 80
84 81 return new WP_REST_Response([
85 82 'message' => BackendStrings::getCommonStrings()['ok'],
86 83 'data' => []