← All changes
|
backend/src/Controllers/Notification/DeleteNotificationController.php
+5
-7
0.1.2
→
1.5
View file →
| @@ -1,13 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Controllers\Notification; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\Common\Exceptions\ForbiddenException; |
| 11 | 6 | use IvyForms\Common\Exceptions\InvalidArgumentException; |
| 12 | 7 | use IvyForms\Common\Exceptions\NotFoundException; |
| 13 | 8 | use IvyForms\Common\Sanitizer\Sanitizer; |
| @@ -12,8 +7,9 @@ | ||
| 12 | 7 | use IvyForms\Common\Exceptions\NotFoundException; |
| 13 | 8 | use IvyForms\Common\Sanitizer\Sanitizer; |
| 14 | 9 | use IvyForms\Controllers\Controller; |
| 15 | 10 | use IvyForms\Services\Notification\NotificationService; |
| 11 | +use IvyForms\Services\Translations\BackendStrings; | |
| 16 | 12 | use WP_REST_Request; |
| 17 | 13 | use WP_REST_Response; |
| 18 | 14 | |
| 19 | 15 | /** |
| @@ -44,15 +40,17 @@ | ||
| 44 | 40 | Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); |
| 45 | 41 | $notificationId = Sanitizer::sanitizeId($data->get_param('id')); |
| 46 | 42 | |
| 47 | 43 | if (empty($notificationId)) { |
| 48 | - throw new InvalidArgumentException('Notification ID is required.'); | |
| 44 | + throw new InvalidArgumentException( | |
| 45 | + BackendStrings::getExceptionStrings()['notification_id_required'] | |
| 46 | + ); | |
| 49 | 47 | } |
| 50 | 48 | |
| 51 | 49 | $this->notificationService->deleteNotification($notificationId); |
| 52 | 50 | |
| 53 | 51 | return new WP_REST_Response([ |
| 54 | - 'message' => 'Successfully deleted notification.', | |
| 52 | + 'message' => BackendStrings::getCommonStrings()['ok'], | |
| 55 | 53 | 'data' => [] |
| 56 | 54 | ], 200); |
| 57 | 55 | } |
| 58 | 56 | } |