PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / trunk
WCPOS – Point of Sale (POS) plugin for WooCommerce vtrunk
1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 1.9.13 1.9.12 1.9.11 1.9.10 1.9.9 All 158 releases
woocommerce-pos / includes / API / V2 / Status_Controller.php

Status_Controller.php in WCPOS – Point of Sale (POS) plugin for WooCommerce trunk, at includes/API/V2/Status_Controller.php

64 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sync status REST API controller.
4 *
5 * @package WCPOS\WooCommercePOS\API\V2
6 */
7
8 namespace WCPOS\WooCommercePOS\API\V2;
9
10 use WCPOS\WooCommercePOS\Sync\Api;
11 use WCPOS\WooCommercePOS\Sync\Endpoint_Permissions;
12 use WCPOS\WooCommercePOS\Sync\Health;
13 use WP_REST_Controller;
14 use WP_REST_Request;
15 use WP_REST_Response;
16 use WP_REST_Server;
17
18 /**
19 * Reports sync store health.
20 */
21 final class Status_Controller extends WP_REST_Controller {
22 use Endpoint_Permissions;
23
24 /**
25 * Register the sync status route.
26 */
27 public function register_routes(): void {
28 register_rest_route(
29 Api::ROUTE_NAMESPACE,
30 '/status',
31 array(
32 'methods' => WP_REST_Server::READABLE,
33 'callback' => array( $this, 'get_status' ),
34 'permission_callback' => array( $this, 'permissions_check' ),
35 )
36 );
37 }
38
39 /**
40 * Get the current sync store health.
41 *
42 * @param WP_REST_Request $request Request object.
43 */
44 public function get_status( WP_REST_Request $request ): WP_REST_Response {
45 $missing_tables = Health::missing_tables();
46
47 return new WP_REST_Response(
48 array(
49 'healthy' => array() === $missing_tables,
50 'missing_tables' => $missing_tables,
51 'schema_version' => get_option( Api::SCHEMA_OPTION, null ),
52 ),
53 200
54 );
55 }
56
57 /**
58 * Allow the status endpoint to report an unhealthy sync store.
59 */
60 protected function health_gated(): bool {
61 return false;
62 }
63 }
64