| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Base; |
| 4 |
|
| 5 |
use JsonSerializable; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
abstract class Element_Control_Base implements JsonSerializable { |
| 12 |
private $label = null; |
| 13 |
private $meta = null; |
| 14 |
|
| 15 |
abstract public function get_type(): string; |
| 16 |
|
| 17 |
abstract public function get_props(): array; |
| 18 |
|
| 19 |
public static function make(): self { |
| 20 |
return new static(); |
| 21 |
} |
| 22 |
|
| 23 |
public function set_label( string $label ): self { |
| 24 |
$this->label = $label; |
| 25 |
|
| 26 |
return $this; |
| 27 |
} |
| 28 |
|
| 29 |
public function get_label(): string { |
| 30 |
return $this->label; |
| 31 |
} |
| 32 |
|
| 33 |
public function set_meta( $meta ): self { |
| 34 |
$this->meta = $meta; |
| 35 |
|
| 36 |
return $this; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_meta(): array { |
| 40 |
return $this->meta; |
| 41 |
} |
| 42 |
|
| 43 |
public function jsonSerialize(): array { |
| 44 |
return [ |
| 45 |
'type' => 'element-control', |
| 46 |
'value' => [ |
| 47 |
'label' => $this->get_label(), |
| 48 |
'meta' => $this->get_meta(), |
| 49 |
'type' => $this->get_type(), |
| 50 |
'props' => $this->get_props(), |
| 51 |
], |
| 52 |
]; |
| 53 |
} |
| 54 |
} |
| 55 |
|