| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\PropsResolver; |
| 4 |
|
| 5 |
use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Transformable_Prop_Type; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
class Props_Resolver_Context { |
| 12 |
private ?string $key = null; |
| 13 |
|
| 14 |
private ?Transformable_Prop_Type $prop_type; |
| 15 |
|
| 16 |
private bool $disabled = false; |
| 17 |
|
| 18 |
private ?Transformers_Registry $transformers_registry = null; |
| 19 |
|
| 20 |
public static function make(): self { |
| 21 |
return new static(); |
| 22 |
} |
| 23 |
|
| 24 |
public function set_key( ?string $key ): self { |
| 25 |
$this->key = $key; |
| 26 |
|
| 27 |
return $this; |
| 28 |
} |
| 29 |
|
| 30 |
public function set_disabled( bool $disabled ): self { |
| 31 |
$this->disabled = $disabled; |
| 32 |
|
| 33 |
return $this; |
| 34 |
} |
| 35 |
|
| 36 |
public function set_prop_type( Transformable_Prop_Type $prop_type ): self { |
| 37 |
$this->prop_type = $prop_type; |
| 38 |
|
| 39 |
return $this; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_key(): ?string { |
| 43 |
return $this->key; |
| 44 |
} |
| 45 |
|
| 46 |
public function is_disabled(): bool { |
| 47 |
return $this->disabled; |
| 48 |
} |
| 49 |
|
| 50 |
public function get_prop_type(): ?Transformable_Prop_Type { |
| 51 |
return $this->prop_type; |
| 52 |
} |
| 53 |
|
| 54 |
public function set_transformers_registry( Transformers_Registry $transformers_registry ): self { |
| 55 |
$this->transformers_registry = $transformers_registry; |
| 56 |
|
| 57 |
return $this; |
| 58 |
} |
| 59 |
|
| 60 |
public function get_transformer( string $prop_type_key ): ?Transformer_Base { |
| 61 |
if ( ! isset( $this->transformers_registry ) ) { |
| 62 |
return null; |
| 63 |
} |
| 64 |
|
| 65 |
return $this->transformers_registry->get( $prop_type_key ); |
| 66 |
} |
| 67 |
} |
| 68 |
|