← All changes
|
backend/src/Controllers/Notification/GetNotificationsController.php
+2
-8
0.1.2
→
1.5.1
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 | /** |
| @@ -41,10 +37,8 @@ | ||
| 41 | 37 | { |
| 42 | 38 | // Verify the nonce |
| 43 | 39 | Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); |
| 44 | 40 | $formId = Sanitizer::sanitizeId($data->get_param('id')); |
| 45 | - | |
| 46 | - | |
| 47 | 41 | // TODO: Update this logic to only require the form ID after templates. |
| 48 | 42 | $notificationsArr = $formId |
| 49 | 43 | ? $this->notificationService->getNotificationsByFormId((int) $formId) |
| 50 | 44 | : $this->notificationService->getAllNotifications(); |
| @@ -55,9 +49,9 @@ | ||
| 55 | 49 | $notifications[] = $notification->toArray(); |
| 56 | 50 | } |
| 57 | 51 | |
| 58 | 52 | return new WP_REST_Response([ |
| 59 | - 'message' => 'OK', | |
| 53 | + 'message' => BackendStrings::getCommonStrings()['ok'], | |
| 60 | 54 | 'data' => $notifications, |
| 61 | 55 | ], 200); |
| 62 | 56 | } |
| 63 | 57 | } |