PluginProbe
The Innovative Form Builder – IvyForms / 0.5
The Innovative Form Builder – IvyForms v0.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
ivyforms / backend / src / Routes / Notification / Notification.php

Notification.php in The Innovative Form Builder – IvyForms 0.5, at backend/src/Routes/Notification/Notification.php

115 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Routes\Notification;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Vendor\DI\Container;
11 use IvyForms\Vendor\DI\DependencyException;
12 use IvyForms\Vendor\DI\NotFoundException;
13 use IvyForms\Controllers\Notification\AddNotificationController;
14 use IvyForms\Controllers\Notification\DeleteNotificationController;
15 use IvyForms\Controllers\Notification\DuplicateNotificationController;
16 use IvyForms\Controllers\Notification\GetNotificationController;
17 use IvyForms\Controllers\Notification\GetNotificationsController;
18 use IvyForms\Controllers\Notification\SearchNotificationsController;
19 use IvyForms\Controllers\Notification\UpdateNotificationController;
20 use WP_REST_Server;
21
22 class Notification
23 {
24 /**
25 * @throws DependencyException
26 * @throws NotFoundException
27 */
28 public static function registerRoutes(Container $container, string $routeNamespace): void
29 {
30 register_rest_route(
31 $routeNamespace,
32 '/notification/(?P<id>\d+)',
33 [
34 'methods' => WP_REST_Server::READABLE,
35 'callback' => $container->get(GetNotificationController::class),
36 'permission_callback' => function () {
37 return current_user_can('manage_options');
38 },
39 ]
40 );
41
42 register_rest_route(
43 $routeNamespace,
44 '/notifications/(?P<id>\d+)',
45 [
46 'methods' => WP_REST_Server::READABLE,
47 'callback' => $container->get(GetNotificationsController::class),
48 'permission_callback' => function () {
49 return current_user_can('manage_options');
50 }
51 ]
52 );
53
54 register_rest_route(
55 $routeNamespace,
56 '/notification/add/',
57 [
58 'methods' => WP_REST_Server::CREATABLE,
59 'callback' => $container->get(AddNotificationController::class),
60 'permission_callback' => function () {
61 return current_user_can('manage_options');
62 }
63 ]
64 );
65
66 register_rest_route(
67 $routeNamespace,
68 '/notification/update/(?P<id>\d+)',
69 [
70 'methods' => WP_REST_Server::CREATABLE,
71 'callback' => $container->get(UpdateNotificationController::class),
72 'permission_callback' => function () {
73 return current_user_can('manage_options');
74 }
75 ]
76 );
77
78 register_rest_route(
79 $routeNamespace,
80 '/notification/delete/(?P<id>\d+)',
81 [
82 'methods' => WP_REST_Server::CREATABLE,
83 'callback' => $container->get(DeleteNotificationController::class),
84 'permission_callback' => function () {
85 return current_user_can('manage_options');
86 }
87 ]
88 );
89 register_rest_route(
90 $routeNamespace,
91 '/notification/duplicate/(?P<id>\d+)',
92 [
93 'methods' => WP_REST_Server::CREATABLE,
94 'callback' => $container->get(DuplicateNotificationController::class),
95 // TODO - Add IvyForms capability - Admin only for now
96 'permission_callback' => function () {
97 return current_user_can('manage_options');
98 }
99 ]
100 );
101
102 register_rest_route(
103 $routeNamespace,
104 '/notifications/search',
105 [
106 'methods' => WP_REST_Server::READABLE,
107 'callback' => $container->get(SearchNotificationsController::class),
108 'permission_callback' => function () {
109 return current_user_can('manage_options');
110 }
111 ]
112 );
113 }
114 }
115