PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.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 / Permissions / Permissions.php

Permissions.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Routes/Permissions/Permissions.php

84 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © Melograno Venture Studio. All rights reserved.
5 */
6
7 namespace IvyForms\Routes\Permissions;
8
9 // phpcs:disable PSR1.Files.SideEffects
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13
14 use IvyForms\Controllers\Permissions\GetAccessRulesController;
15 use IvyForms\Controllers\Permissions\GetPermissionsMetaController;
16 use IvyForms\Controllers\Permissions\SearchPermissionsUsersController;
17 use IvyForms\Controllers\Permissions\UpdateAccessRulesController;
18 use IvyForms\Services\Permissions\IvyFormsAccess;
19 use IvyForms\Vendor\DI\Container;
20 use IvyForms\Vendor\DI\DependencyException;
21 use IvyForms\Vendor\DI\NotFoundException;
22 use WP_REST_Server;
23
24 class Permissions
25 {
26 /**
27 * @throws DependencyException
28 * @throws NotFoundException
29 */
30 public static function registerRoutes(Container $container, string $routeNamespace): void
31 {
32 register_rest_route(
33 $routeNamespace,
34 '/permissions/access-rules',
35 [
36 [
37 'methods' => WP_REST_Server::READABLE,
38 'callback' => $container->get(GetAccessRulesController::class),
39 'permission_callback' => static function () {
40 return IvyFormsAccess::currentUserCanAccessPermissionsSettings();
41 },
42 ],
43 [
44 'methods' => WP_REST_Server::EDITABLE,
45 'callback' => $container->get(UpdateAccessRulesController::class),
46 'permission_callback' => static function () {
47 return IvyFormsAccess::currentUserCanAccessPermissionsSettings();
48 },
49 ],
50 ]
51 );
52
53 register_rest_route(
54 $routeNamespace,
55 '/permissions/meta',
56 [
57 'methods' => WP_REST_Server::READABLE,
58 'callback' => $container->get(GetPermissionsMetaController::class),
59 'permission_callback' => static function () {
60 return IvyFormsAccess::currentUserCanAccessPermissionsSettings();
61 },
62 ]
63 );
64
65 register_rest_route(
66 $routeNamespace,
67 '/permissions/users',
68 [
69 'methods' => WP_REST_Server::READABLE,
70 'callback' => $container->get(SearchPermissionsUsersController::class),
71 'permission_callback' => static function () {
72 return IvyFormsAccess::currentUserCanAccessPermissionsSettings();
73 },
74 'args' => [
75 'search' => [
76 'required' => false,
77 'type' => 'string',
78 ],
79 ],
80 ]
81 );
82 }
83 }
84