PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.4
Elementor Website Builder – more than just a page builder v4.1.4
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / app / modules / import-export-customization / data / response.php

response.php in Elementor Website Builder – more than just a page builder 4.1.4, at app/modules/import-export-customization/data/response.php

39 lines 925 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\App\Modules\ImportExportCustomization\Data;
4
5 class Response {
6 private array $data;
7 private array $meta;
8
9 public function __construct( array $data, array $meta = [] ) {
10 $this->data = $data;
11 $this->meta = $meta;
12 }
13
14 public static function success( array $data, array $meta = [] ): \WP_REST_Response {
15 $response = new self( $data, $meta );
16 return $response->to_wp_rest_response( 200 );
17 }
18
19 public static function error( string $code, $message, array $meta = [] ): \WP_REST_Response {
20 $response = new self([
21 'code' => $code,
22 'message' => $message,
23 ], $meta);
24
25 return $response->to_wp_rest_response( 500 );
26 }
27
28 private function to_array(): array {
29 return [
30 'data' => $this->data,
31 'meta' => $this->meta,
32 ];
33 }
34
35 private function to_wp_rest_response( int $status_code = 200 ): \WP_REST_Response {
36 return new \WP_REST_Response( $this->to_array(), $status_code );
37 }
38 }
39