| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\PropsResolver; |
| 4 |
|
| 5 |
use Elementor\Core\Utils\Collection; |
| 6 |
use Elementor\Utils; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
class Transformers_Registry extends Collection { |
| 13 |
private ?Transformer_Base $fallback = null; |
| 14 |
|
| 15 |
public function register( string $key, Transformer_Base $transformer ): self { |
| 16 |
$this->items[ $key ] = $transformer; |
| 17 |
|
| 18 |
return $this; |
| 19 |
} |
| 20 |
|
| 21 |
public function register_fallback( Transformer_Base $transformer ): self { |
| 22 |
$this->fallback = $transformer; |
| 23 |
|
| 24 |
return $this; |
| 25 |
} |
| 26 |
|
| 27 |
public function get( $key, $fallback = null ) { |
| 28 |
return parent::get( $key, $fallback ?? $this->fallback ); |
| 29 |
} |
| 30 |
} |
| 31 |
|