PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
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 1.1, at backend/src/Routes/Notification/Notification.php

110 lines 3.8 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 use IvyForms\Vendor\DI\Container;
6 use IvyForms\Vendor\DI\DependencyException;
7 use IvyForms\Vendor\DI\NotFoundException;
8 use IvyForms\Controllers\Notification\AddNotificationController;
9 use IvyForms\Controllers\Notification\DeleteNotificationController;
10 use IvyForms\Controllers\Notification\DuplicateNotificationController;
11 use IvyForms\Controllers\Notification\GetNotificationController;
12 use IvyForms\Controllers\Notification\GetNotificationsController;
13 use IvyForms\Controllers\Notification\SearchNotificationsController;
14 use IvyForms\Controllers\Notification\UpdateNotificationController;
15 use WP_REST_Server;
16
17 class Notification
18 {
19 /**
20 * @throws DependencyException
21 * @throws NotFoundException
22 */
23 public static function registerRoutes(Container $container, string $routeNamespace): void
24 {
25 register_rest_route(
26 $routeNamespace,
27 '/notification/(?P<id>\d+)',
28 [
29 'methods' => WP_REST_Server::READABLE,
30 'callback' => $container->get(GetNotificationController::class),
31 'permission_callback' => function () {
32 return current_user_can('manage_options');
33 },
34 ]
35 );
36
37 register_rest_route(
38 $routeNamespace,
39 '/notifications/(?P<id>\d+)',
40 [
41 'methods' => WP_REST_Server::READABLE,
42 'callback' => $container->get(GetNotificationsController::class),
43 'permission_callback' => function () {
44 return current_user_can('manage_options');
45 }
46 ]
47 );
48
49 register_rest_route(
50 $routeNamespace,
51 '/notification/add/',
52 [
53 'methods' => WP_REST_Server::CREATABLE,
54 'callback' => $container->get(AddNotificationController::class),
55 'permission_callback' => function () {
56 return current_user_can('manage_options');
57 }
58 ]
59 );
60
61 register_rest_route(
62 $routeNamespace,
63 '/notification/update/(?P<id>\d+)',
64 [
65 'methods' => WP_REST_Server::CREATABLE,
66 'callback' => $container->get(UpdateNotificationController::class),
67 'permission_callback' => function () {
68 return current_user_can('manage_options');
69 }
70 ]
71 );
72
73 register_rest_route(
74 $routeNamespace,
75 '/notification/delete/(?P<id>\d+)',
76 [
77 'methods' => WP_REST_Server::CREATABLE,
78 'callback' => $container->get(DeleteNotificationController::class),
79 'permission_callback' => function () {
80 return current_user_can('manage_options');
81 }
82 ]
83 );
84 register_rest_route(
85 $routeNamespace,
86 '/notification/duplicate/(?P<id>\d+)',
87 [
88 'methods' => WP_REST_Server::CREATABLE,
89 'callback' => $container->get(DuplicateNotificationController::class),
90 // TODO - Add IvyForms capability - Admin only for now
91 'permission_callback' => function () {
92 return current_user_can('manage_options');
93 }
94 ]
95 );
96
97 register_rest_route(
98 $routeNamespace,
99 '/notifications/search',
100 [
101 'methods' => WP_REST_Server::READABLE,
102 'callback' => $container->get(SearchNotificationsController::class),
103 'permission_callback' => function () {
104 return current_user_can('manage_options');
105 }
106 ]
107 );
108 }
109 }
110