PluginProbe
WooCommerce / 11.1.0-beta.2
WooCommerce v11.1.0-beta.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / StoreApi / Schemas / V1 / ErrorSchema.php
ErrorSchema.php
58 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Automattic\WooCommerce\StoreApi\Schemas\V1;
3
4 /**
5 * ErrorSchema class.
6 */
7 class ErrorSchema extends AbstractSchema {
8 /**
9 * The schema item name.
10 *
11 * @var string
12 */
13 protected $title = 'error';
14
15 /**
16 * The schema item identifier.
17 *
18 * @var string
19 */
20 const IDENTIFIER = 'error';
21
22 /**
23 * Product schema properties.
24 *
25 * @return array
26 */
27 public function get_properties() {
28 return [
29 'code' => [
30 'description' => __( 'Error code', 'woocommerce' ),
31 'type' => 'string',
32 'context' => [ 'view', 'edit' ],
33 'readonly' => true,
34 ],
35 'message' => [
36 'description' => __( 'Error message', 'woocommerce' ),
37 'type' => 'string',
38 'context' => [ 'view', 'edit' ],
39 'readonly' => true,
40 ],
41 ];
42 }
43
44 /**
45 * Convert a WP_Error into an object suitable for the response.
46 *
47 * @param \WP_Error $error Error object.
48 * @return array
49 */
50 public function get_item_response( $error ) {
51 return [
52 'code' => $this->prepare_html_response( $error->get_error_code() ),
53 'message' => $this->prepare_html_response( $error->get_error_message() ),
54 ];
55 }
56
57 }
58