| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Elements; |
| 4 |
|
| 5 |
class Widget_Builder { |
| 6 |
protected $widget_type; |
| 7 |
protected $settings = []; |
| 8 |
protected $is_locked = false; |
| 9 |
protected $editor_settings = []; |
| 10 |
|
| 11 |
public static function make( string $widget_type ) { |
| 12 |
return new self( $widget_type ); |
| 13 |
} |
| 14 |
|
| 15 |
private function __construct( string $widget_type ) { |
| 16 |
$this->widget_type = $widget_type; |
| 17 |
} |
| 18 |
|
| 19 |
public function settings( array $settings ) { |
| 20 |
$this->settings = $settings; |
| 21 |
return $this; |
| 22 |
} |
| 23 |
|
| 24 |
public function is_locked( $is_locked ) { |
| 25 |
$this->is_locked = $is_locked; |
| 26 |
return $this; |
| 27 |
} |
| 28 |
|
| 29 |
public function editor_settings( array $editor_settings ) { |
| 30 |
$this->editor_settings = $editor_settings; |
| 31 |
return $this; |
| 32 |
} |
| 33 |
|
| 34 |
public function build() { |
| 35 |
$widget_data = [ |
| 36 |
'elType' => 'widget', |
| 37 |
'widgetType' => $this->widget_type, |
| 38 |
'settings' => $this->settings, |
| 39 |
'isLocked' => $this->is_locked, |
| 40 |
'editor_settings' => $this->editor_settings, |
| 41 |
]; |
| 42 |
|
| 43 |
return $widget_data; |
| 44 |
} |
| 45 |
} |
| 46 |
|