PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.1
Elementor Website Builder – more than just a page builder v3.30.1
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 / modules / global-classes / utils / response-builder.php

response-builder.php in Elementor Website Builder – more than just a page builder 3.30.1, at modules/global-classes/utils/response-builder.php

49 lines 898 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\GlobalClasses\Utils;
4
5 class Response_Builder {
6 private $data;
7 private int $status;
8 private array $meta = [];
9 private bool $empty = false;
10
11 const NO_CONTENT = 204;
12
13 private function __construct( $data, $status ) {
14 $this->data = $data;
15 $this->status = $status;
16 }
17
18 public static function make( $data = null, $status = 200 ) {
19 return new self( $data, $status );
20 }
21
22 public function set_meta( array $meta ) {
23 $this->meta = $meta;
24
25 return $this;
26 }
27
28 public function set_status( int $status ) {
29 $this->status = $status;
30
31 return $this;
32 }
33
34 public function no_content() {
35 return $this->set_status( static::NO_CONTENT );
36 }
37
38 public function build() {
39 $res_data = static::NO_CONTENT === $this->status
40 ? null
41 : [
42 'data' => $this->data,
43 'meta' => $this->meta,
44 ];
45
46 return new \WP_REST_Response( $res_data, $this->status );
47 }
48 }
49