# ivyforms/0.8/backend/src/Controllers/Notification/DeleteNotificationController.php

The Innovative Form Builder – IvyForms, version 0.8. 62 lines.

- Page: https://pluginprobe.com/plugins/ivyforms/0.8/code/backend/src/Controllers/Notification/DeleteNotificationController.php
- Raw: https://pluginprobe.com/plugins/ivyforms/0.8/raw/backend/src/Controllers/Notification/DeleteNotificationController.php
- Modified: 2026-01-13T11:11:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ivyforms/0.8/code/backend/src/Controllers/Notification/DeleteNotificationController.php#L10-L20`.

```php
<?php

namespace IvyForms\Controllers\Notification;

// phpcs:disable PSR1.Files.SideEffects
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

use IvyForms\Common\Exceptions\ForbiddenException;
use IvyForms\Common\Exceptions\InvalidArgumentException;
use IvyForms\Common\Exceptions\NotFoundException;
use IvyForms\Common\Sanitizer\Sanitizer;
use IvyForms\Controllers\Controller;
use IvyForms\Services\Notification\NotificationService;
use IvyForms\Services\Translations\BackendStrings;
use WP_REST_Request;
use WP_REST_Response;

/**
 * Class DeleteNotificationController
 *
 * @package IvyForms\Controllers\Notification
 */
class DeleteNotificationController extends Controller
{
    private NotificationService $notificationService;

    public function __construct(NotificationService $notificationService)
    {
        $this->notificationService = $notificationService;
    }

    /**
     * @param WP_REST_Request $data
     *
     * @return WP_REST_Response
     *
     * @throws InvalidArgumentException
     * @throws ForbiddenException
     */
    public function handle(WP_REST_Request $data): WP_REST_Response
    {
        // Verify the nonce
        Sanitizer::verifyNonce($data->get_header('X-WP-Nonce'));
        $notificationId = Sanitizer::sanitizeId($data->get_param('id'));

        if (empty($notificationId)) {
            throw new InvalidArgumentException(
                BackendStrings::getExceptionStrings()['notification_id_required']
            );
        }

        $this->notificationService->deleteNotification($notificationId);

        return new WP_REST_Response([
            'message' => BackendStrings::getCommonStrings()['ok'],
            'data'    => []
        ], 200);
    }
}

```
