| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Styles; |
| 4 |
|
| 5 |
use Elementor\Modules\AtomicWidgets\PropsResolver\Render_Props_Resolver; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
class Style_Props_To_Css { |
| 12 |
|
| 13 |
/** |
| 14 |
* Resolve a map of style PropValue envelopes into a flat `{cssProp: cssValue}` map. |
| 15 |
* Null/empty resolved values are filtered out. |
| 16 |
* |
| 17 |
* @param array<string, mixed> $props Style props as stored (PropValue envelopes). |
| 18 |
* @return array<string, string> |
| 19 |
*/ |
| 20 |
public static function to_map( array $props ): array { |
| 21 |
if ( empty( $props ) ) { |
| 22 |
return []; |
| 23 |
} |
| 24 |
|
| 25 |
$resolved = Render_Props_Resolver::for_styles()->resolve( Style_Schema::get(), $props ); |
| 26 |
|
| 27 |
return array_filter( $resolved, fn( $value ) => null !== $value && '' !== $value ); |
| 28 |
} |
| 29 |
} |
| 30 |
|