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

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