PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 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 All 452 releases
elementor / modules / atomic-widgets / elements / base / element-builder.php

element-builder.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/atomic-widgets/elements/base/element-builder.php

76 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Elements\Base;
4
5 class Element_Builder {
6 protected $element_type;
7 protected $settings = [];
8 protected $is_locked = false;
9 protected $children = [];
10 protected $editor_settings = [];
11 protected $meta = [];
12 protected $hydrate_default_children = false;
13
14 public static function make( string $element_type ) {
15 return new self( $element_type );
16 }
17
18 private function __construct( string $element_type ) {
19 $this->element_type = $element_type;
20 }
21
22 public function settings( array $settings ) {
23 $this->settings = $settings;
24 return $this;
25 }
26
27 public function is_locked( $is_locked ) {
28 $this->is_locked = $is_locked;
29 return $this;
30 }
31
32 public function editor_settings( array $editor_settings ) {
33 $this->editor_settings = $editor_settings;
34 return $this;
35 }
36
37 public function children( array $children ) {
38 $this->children = $children;
39 return $this;
40 }
41
42 public function meta( array $meta ) {
43 $this->meta = $meta;
44 return $this;
45 }
46
47 /**
48 * Marks this payload to seed its default children client-side (via
49 * `AtomicElementBaseModel::onElementCreate()`) once inserted into the editor.
50 */
51 public function hydrate_default_children( bool $hydrate = true ) {
52 $this->hydrate_default_children = $hydrate;
53 return $this;
54 }
55
56 public function build() {
57 $element_data = [
58 'elType' => $this->element_type,
59 'settings' => $this->settings,
60 'isLocked' => $this->is_locked,
61 'editor_settings' => $this->editor_settings,
62 'elements' => $this->children,
63 ];
64
65 if ( ! empty( $this->meta ) ) {
66 $element_data['meta'] = $this->meta;
67 }
68
69 if ( $this->hydrate_default_children ) {
70 $element_data['hydrateDefaultChildren'] = true;
71 }
72
73 return $element_data;
74 }
75 }
76