/var/www/html_uk/wp-content/plugins/automatewoo/includes/Factories.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
<?php

namespace AutomateWoo;

/**
 * @class Factories
 * @since 2.9
 */
class Factories {

    
/** @var array */
    
private static $factories;


    
/**
     * Get the Application factories
     *
     * @return array The factories
     */
    
public static function get_factories() {
        if ( ! isset( 
self::$factories ) ) {
            
self::$factories apply_filters(
                
'automatewoo/factories',
                [
                    
'guest'    => 'AutomateWoo\Guest_Factory',
                    
'queue'    => 'AutomateWoo\Queued_Event_Factory',
                    
'log'      => 'AutomateWoo\Log_Factory',
                    
'cart'     => 'AutomateWoo\Cart_Factory',
                    
'customer' => 'AutomateWoo\Customer_Factory',
                ]
            );
        }
        return 
self::$factories;
    }


    
/**
     * Gets a Factory
     *
     * @param string $type The factory to get
     * @return bool|Factory
     */
    
public static function get_factory$type ) {

        if ( ! 
$type ) {
            return 
false;
        }

        
$factories self::get_factories();

        return isset( 
$factories$type ] ) ? $factories$type ] : false;
    }


    
/**
     * Updates the cache for a Factory
     *
     * @param Model $object The object to update its factory cache
     */
    
public static function update_object_cache$object ) {
        
$factory self::get_factory$object->object_type );
        if ( 
$factory ) {
            
$factory::update_cache$object );
        } else {
            
_doing_it_wrong__FUNCTION__esc_html__'Factory class must be registered.''automatewoo' ) ), '2.9.0' );
        }
    }


    
/**
     * Cleans the cache for a Factory
     *
     * @param Model $object The object to clean its factory cache
     */
    
public static function clean_object_cache$object ) {
        
$factory self::get_factory$object->object_type );
        if ( 
$factory ) {
            
$factory::clean_cache$object );
        }
    }
}