| 1 |
<?php |
| 2 |
namespace Elementor\Modules\AtomicWidgets\Controls; |
| 3 |
|
| 4 |
use JsonSerializable; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly. |
| 8 |
} |
| 9 |
|
| 10 |
class Section implements JsonSerializable { |
| 11 |
private ?string $id = null; |
| 12 |
private $label = null; |
| 13 |
private $description = null; |
| 14 |
private array $items = []; |
| 15 |
|
| 16 |
public static function make(): self { |
| 17 |
return new static(); |
| 18 |
} |
| 19 |
|
| 20 |
public function set_id( string $id ): self { |
| 21 |
$this->id = $id; |
| 22 |
|
| 23 |
return $this; |
| 24 |
} |
| 25 |
|
| 26 |
public function get_id() { |
| 27 |
return $this->id; |
| 28 |
} |
| 29 |
|
| 30 |
public function set_label( string $label ): self { |
| 31 |
$this->label = html_entity_decode( $label ); |
| 32 |
|
| 33 |
return $this; |
| 34 |
} |
| 35 |
|
| 36 |
public function get_label(): ?string { |
| 37 |
return $this->label; |
| 38 |
} |
| 39 |
|
| 40 |
public function set_description( string $description ): self { |
| 41 |
$this->description = html_entity_decode( $description ); |
| 42 |
|
| 43 |
return $this; |
| 44 |
} |
| 45 |
|
| 46 |
public function set_items( array $items ): self { |
| 47 |
$this->items = $items; |
| 48 |
|
| 49 |
return $this; |
| 50 |
} |
| 51 |
|
| 52 |
public function add_item( $item ): self { |
| 53 |
$this->items[] = $item; |
| 54 |
|
| 55 |
return $this; |
| 56 |
} |
| 57 |
|
| 58 |
public function get_items() { |
| 59 |
return $this->items; |
| 60 |
} |
| 61 |
|
| 62 |
public function jsonSerialize(): array { |
| 63 |
return [ |
| 64 |
'type' => 'section', |
| 65 |
'value' => [ |
| 66 |
'id' => $this->id, |
| 67 |
'label' => $this->label, |
| 68 |
'description' => $this->description, |
| 69 |
'items' => $this->items, |
| 70 |
], |
| 71 |
]; |
| 72 |
} |
| 73 |
} |
| 74 |
|