PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.4
Elementor Website Builder – more than just a page builder v4.2.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 / core / utils / api / response-builder.php

response-builder.php in Elementor Website Builder – more than just a page builder 4.2.4, at core/utils/api/response-builder.php

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