← All changes
|
modules/atomic-widgets/base/atomic-control-base.php
+55
-6
4.2.2
→
3.32.0-dev3
View file →
| @@ -1,15 +1,64 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\AtomicWidgets\Base; |
| 4 | 4 | |
| 5 | -use Elementor\Modules\AtomicWidgets\Controls\Base\Atomic_Control_Base as New_Atomic_Control_Base; | |
| 5 | +use JsonSerializable; | |
| 6 | 6 | |
| 7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | 8 | exit; // Exit if accessed directly. |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -// TODO: Remove this class after 3.36 is released. | |
| 12 | -/** | |
| 13 | - * @deprecated 3.34 Use \Elementor\Modules\AtomicWidgets\Controls\Base\Atomic_Control_Base instead. | |
| 14 | - */ | |
| 15 | -abstract class Atomic_Control_Base extends New_Atomic_Control_Base {} | |
| 11 | +abstract class Atomic_Control_Base implements JsonSerializable { | |
| 12 | + private string $bind; | |
| 13 | + private $label = null; | |
| 14 | + private $description = null; | |
| 15 | + private $meta = null; | |
| 16 | + | |
| 17 | + abstract public function get_type(): string; | |
| 18 | + | |
| 19 | + abstract public function get_props(): array; | |
| 20 | + | |
| 21 | + public static function bind_to( string $prop_name ) { | |
| 22 | + return new static( $prop_name ); | |
| 23 | + } | |
| 24 | + | |
| 25 | + protected function __construct( string $prop_name ) { | |
| 26 | + $this->bind = $prop_name; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public function get_bind() { | |
| 30 | + return $this->bind; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public function set_label( string $label ): self { | |
| 34 | + $this->label = $label; | |
| 35 | + | |
| 36 | + return $this; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public function set_description( string $description ): self { | |
| 40 | + $this->description = $description; | |
| 41 | + | |
| 42 | + return $this; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public function set_meta( $meta ): self { | |
| 46 | + $this->meta = $meta; | |
| 47 | + | |
| 48 | + return $this; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public function jsonSerialize(): array { | |
| 52 | + return [ | |
| 53 | + 'type' => 'control', | |
| 54 | + 'value' => [ | |
| 55 | + 'type' => $this->get_type(), | |
| 56 | + 'bind' => $this->get_bind(), | |
| 57 | + 'label' => $this->label, | |
| 58 | + 'description' => $this->description, | |
| 59 | + 'props' => $this->get_props(), | |
| 60 | + 'meta' => $this->meta, | |
| 61 | + ], | |
| 62 | + ]; | |
| 63 | + } | |
| 64 | +} | |