/var/www/html_de/wp-content/plugins/elementor/modules/variables/classes/style-schema.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php

namespace Elementor\Modules\Variables\Classes;

use 
Elementor\Modules\AtomicWidgets\PropTypes\Base\Array_Prop_Type;
use 
Elementor\Modules\AtomicWidgets\PropTypes\Base\Object_Prop_Type;
use 
Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
use 
Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
use 
Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type;
use 
Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type;
use 
Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly.
}

class 
Style_Schema {
    public function 
augment( array $schema ): array {
        foreach ( 
$schema as $key => $prop_type ) {
            
$schema$key ] = $this->update$prop_type );
        }

        if ( isset( 
$schema['font-family'] ) ) {
            
$schema['font-family'] = $this->update_font_family$schema['font-family'] );
        }

        return 
$schema;
    }

    private function 
update$prop_type ) {
        if ( 
$prop_type instanceof Color_Prop_Type ) {
            return 
$this->update_color$prop_type );
        }

        if ( 
$prop_type instanceof Union_Prop_Type ) {
            return 
$this->update_union$prop_type );
        }

        if ( 
$prop_type instanceof Object_Prop_Type ) {
            return 
$this->update_object$prop_type );
        }

        if ( 
$prop_type instanceof Array_Prop_Type ) {
            return 
$this->update_array$prop_type );
        }

        return 
$prop_type;
    }

    private function 
update_font_familyString_Prop_Type $prop_type ): Union_Prop_Type {
        return 
Union_Prop_Type::create_from$prop_type )
            ->
add_prop_typeFont_Variable_Prop_Type::make() );
    }

    private function 
update_colorColor_Prop_Type $color_prop_type ): Union_Prop_Type {
        return 
Union_Prop_Type::create_from$color_prop_type )
            ->
add_prop_typeColor_Variable_Prop_Type::make() );
    }

    private function 
update_arrayArray_Prop_Type $array_prop_type ): Array_Prop_Type {
        return 
$array_prop_type->set_item_type(
            
$this->update$array_prop_type->get_item_type() )
        );
    }

    private function 
update_objectObject_Prop_Type $object_prop_type ): Object_Prop_Type {
        return 
$object_prop_type->set_shape(
            
$this->augment$object_prop_type->get_shape() )
        );
    }

    private function 
update_unionUnion_Prop_Type $union_prop_type ): Union_Prop_Type {
        
$new_union Union_Prop_Type::make();
        
$dependencies $union_prop_type->get_dependencies();
        
$new_union->set_dependencies$dependencies );

        foreach ( 
$union_prop_type->get_prop_types() as $prop_type ) {
            
$updated $this->update$prop_type );

            if ( 
$updated instanceof Union_Prop_Type ) {
                foreach ( 
$updated->get_prop_types() as $updated_prop_type ) {
                    
$new_union->add_prop_type$updated_prop_type );
                }

                continue;
            }

            
$new_union->add_prop_type$updated );
        }

        return 
$new_union;
    }
}