PluginProbe
The Innovative Form Builder – IvyForms / 1.4.1
The Innovative Form Builder – IvyForms v1.4.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 / Controllers / GoogleSheets / GoogleSheetsStatusController.php

GoogleSheetsStatusController.php in The Innovative Form Builder – IvyForms 1.4.1, at backend/src/Controllers/GoogleSheets/GoogleSheetsStatusController.php

39 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Controllers\GoogleSheets;
4
5 use IvyForms\Common\Exceptions\ForbiddenException;
6 use IvyForms\Common\Sanitizer\Sanitizer;
7 use IvyForms\Controllers\Controller;
8 use IvyForms\Services\GoogleSheets\GoogleSheetsService;
9 use WP_REST_Request;
10 use WP_REST_Response;
11
12 class GoogleSheetsStatusController extends Controller
13 {
14 private GoogleSheetsService $googleSheetsService;
15
16 public function __construct(GoogleSheetsService $googleSheetsService)
17 {
18 $this->googleSheetsService = $googleSheetsService;
19 }
20
21 /**
22 * @throws ForbiddenException
23 */
24 protected function handle(WP_REST_Request $data): WP_REST_Response
25 {
26 Sanitizer::verifyNonce($data->get_header('X-WP-Nonce'));
27
28 $settings = $this->googleSheetsService->getSettings();
29 $isConnected = $this->googleSheetsService->isConnected();
30
31 return new WP_REST_Response([
32 'connected' => $isConnected,
33 'email' => $isConnected
34 ? ($settings['accountEmail'] ?? $settings['clientEmail'] ?? '')
35 : '',
36 ], 200);
37 }
38 }
39