PluginProbe
The Innovative Form Builder – IvyForms / 0.6.1.1
The Innovative Form Builder – IvyForms v0.6.1.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 / Integrations / Integrations.php

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

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