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