PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / API / Route.php

Route.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/Performance/API/Route.php

87 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The contract defining required methods for a REST route.
4 *
5 * @since 0.1.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 namespace SolidWP\Performance\API;
11
12 use WP_Error;
13 use WP_REST_Request;
14 use WP_REST_Response;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * The contract defining required methods for a REST route.
22 *
23 * @since 0.1.0
24 *
25 * @package SolidWP\Performance
26 */
27 interface Route {
28 /**
29 * Get the path pattern of the REST API endpoint (e.g. '/author/(?P<id>\d+)').
30 *
31 * @since 0.1.0
32 *
33 * @return string
34 */
35 public function get_path(): string;
36
37 /**
38 * Gets the HTTP methods that the REST API endpoint responds to.
39 *
40 * @since 0.1.0
41 *
42 * @return mixed
43 */
44 public function get_methods();
45
46 /**
47 * The action performed by the REST API endpoint to send a response.
48 *
49 * @since 0.1.0
50 *
51 * @param WP_REST_Request $request The current request for the route.
52 *
53 * @return WP_REST_Response|WP_Error
54 */
55 public function callback( WP_REST_Request $request );
56
57 /**
58 * Gets the expected arguments for the REST API endpoint.
59 *
60 * Having an index of the HTTP method (e.g. POST, GET) will apply the args directly to
61 * that method if the route is more than one method.
62 *
63 * @since 0.1.0
64 *
65 * @return array<string, array<string, mixed[]>>
66 */
67 public function get_arguments(): array;
68
69 /**
70 * Ensures user can make a request to the REST API endpoint.
71 *
72 * @since 0.1.0
73 *
74 * @return bool
75 */
76 public function permission_callback(): bool;
77
78 /**
79 * The callback used to output schema for the route.
80 *
81 * @since 0.1.0
82 *
83 * @return array
84 */
85 public function schema_callback(): array;
86 }
87