PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
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 / Integrations / Integrations.php

Integrations.php in The Innovative Form Builder – IvyForms 1.0, at backend/src/Routes/Integrations/Integrations.php

72 lines 2.2 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\Integrations;
4
5 use IvyForms\Vendor\DI\Container;
6 use IvyForms\Vendor\DI\DependencyException;
7 use IvyForms\Vendor\DI\NotFoundException;
8 use IvyForms\Controllers\Integrations\InstallPluginController;
9 use IvyForms\Controllers\Integration\GetAllIntegrationsController;
10 use IvyForms\Controllers\Integration\GetIntegrationController;
11
12 /**
13 * Class Integrations
14 *
15 * Registers REST API routes for integrations
16 *
17 * @package IvyForms\Routes\Integrations
18 */
19 class Integrations
20 {
21 /**
22 * Register integrations routes
23 *
24 * @param Container $container
25 * @param string $routeNamespace
26 *
27 * @throws DependencyException
28 * @throws NotFoundException
29 */
30 public static function registerRoutes(Container $container, string $routeNamespace): void
31 {
32 // Get all integrations
33 register_rest_route(
34 $routeNamespace,
35 '/integrations',
36 [
37 'methods' => 'GET',
38 'callback' => $container->get(GetAllIntegrationsController::class),
39 'permission_callback' => function () {
40 return current_user_can('manage_options');
41 },
42 ]
43 );
44
45 // Get single integration
46 register_rest_route(
47 $routeNamespace,
48 '/integrations/(?P<slug>[a-zA-Z0-9_-]+)',
49 [
50 'methods' => 'GET',
51 'callback' => $container->get(GetIntegrationController::class),
52 'permission_callback' => function () {
53 return current_user_can('manage_options');
54 },
55 ]
56 );
57
58 // Install plugin endpoint
59 register_rest_route(
60 $routeNamespace,
61 '/integrations/install-plugin',
62 [
63 'methods' => 'POST',
64 'callback' => [$container->get(InstallPluginController::class), 'install'],
65 'permission_callback' => function () {
66 return current_user_can('install_plugins') && current_user_can('activate_plugins');
67 },
68 ]
69 );
70 }
71 }
72