Completed
Branch FET-10694-dependency-map (97a6bf)
by
unknown
144:39 queued 132:37
created
strategies/normalization/EE_Normalization_Strategy_Base.strategy.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -14,60 +14,60 @@  discard block
 block discarded – undo
14 14
 abstract class EE_Normalization_Strategy_Base extends EE_Form_Input_Strategy_Base
15 15
 {
16 16
 
17
-    /**
18
-     * Takes the sanitized value for the input and casts it into the correct PHP type.
19
-     * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation
20
-     * strategy should be able to depend on the normalized value being of the correct type.
21
-     * If the normalized value passes validation, the normalized value is what other code
22
-     * will operate on. If the sanitized value cannot be normalized, this method should either
23
-     * add a validation error onto the input, or wrangle the input into a format that can be normalized
24
-     * (eg, for a date input, if the user enters "2014/100/100", you can either add an error stating
25
-     * "hey! 2014/100/100 is not a valid date!", or simply convert it into a valid date like "2014/12/31".
26
-     * For this case, I'd prefer the former. But there may be cases where you'd just rather correct it for them)
27
-     *
28
-     * @param string $value_to_normalize it should always be a string. If the input receives an array, then the
29
-     *                                   validation strategy should be called on array elements, not on the entire array
30
-     * @return mixed the normalized value
31
-     */
32
-    abstract public function normalize($value_to_normalize);
17
+	/**
18
+	 * Takes the sanitized value for the input and casts it into the correct PHP type.
19
+	 * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation
20
+	 * strategy should be able to depend on the normalized value being of the correct type.
21
+	 * If the normalized value passes validation, the normalized value is what other code
22
+	 * will operate on. If the sanitized value cannot be normalized, this method should either
23
+	 * add a validation error onto the input, or wrangle the input into a format that can be normalized
24
+	 * (eg, for a date input, if the user enters "2014/100/100", you can either add an error stating
25
+	 * "hey! 2014/100/100 is not a valid date!", or simply convert it into a valid date like "2014/12/31".
26
+	 * For this case, I'd prefer the former. But there may be cases where you'd just rather correct it for them)
27
+	 *
28
+	 * @param string $value_to_normalize it should always be a string. If the input receives an array, then the
29
+	 *                                   validation strategy should be called on array elements, not on the entire array
30
+	 * @return mixed the normalized value
31
+	 */
32
+	abstract public function normalize($value_to_normalize);
33 33
 
34 34
 
35 35
 
36
-    /**
37
-     * Identical to normalize, except normalize_one() CANNOT be passed an array and
38
-     * never returns an array. Useful if the normalization strategy converts between arrays
39
-     *
40
-     * @param string $individual_item_to_normalize
41
-     * @return mixed
42
-     */
43
-    public function normalize_one($individual_item_to_normalize)
44
-    {
45
-        return $this->normalize($individual_item_to_normalize);
46
-    }
36
+	/**
37
+	 * Identical to normalize, except normalize_one() CANNOT be passed an array and
38
+	 * never returns an array. Useful if the normalization strategy converts between arrays
39
+	 *
40
+	 * @param string $individual_item_to_normalize
41
+	 * @return mixed
42
+	 */
43
+	public function normalize_one($individual_item_to_normalize)
44
+	{
45
+		return $this->normalize($individual_item_to_normalize);
46
+	}
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     * Takes the normalized value (for an Yes_No_Input this could be TRUE or FALSE), and converts it into
52
-     * the value you would use in the html form (for a Yes_No_Input this could be '1' or '0').
53
-     *
54
-     * @param $normalized_value
55
-     * @return array|string the 'raw' value as used in the form, usually a string or array of strings.
56
-     */
57
-    abstract public function unnormalize($normalized_value);
50
+	/**
51
+	 * Takes the normalized value (for an Yes_No_Input this could be TRUE or FALSE), and converts it into
52
+	 * the value you would use in the html form (for a Yes_No_Input this could be '1' or '0').
53
+	 *
54
+	 * @param $normalized_value
55
+	 * @return array|string the 'raw' value as used in the form, usually a string or array of strings.
56
+	 */
57
+	abstract public function unnormalize($normalized_value);
58 58
 
59 59
 
60 60
 
61
-    /**
62
-     * Normally the same as unnormalize, except it CANNOT be passed an array and
63
-     * ALWAYS returns a string
64
-     *
65
-     * @param mixed $individual_item_to_unnormalize NOT an array
66
-     * @return string
67
-     */
68
-    public function unnormalize_one($individual_item_to_unnormalize)
69
-    {
70
-        return $this->unnormalize($individual_item_to_unnormalize);
71
-    }
61
+	/**
62
+	 * Normally the same as unnormalize, except it CANNOT be passed an array and
63
+	 * ALWAYS returns a string
64
+	 *
65
+	 * @param mixed $individual_item_to_unnormalize NOT an array
66
+	 * @return string
67
+	 */
68
+	public function unnormalize_one($individual_item_to_unnormalize)
69
+	{
70
+		return $this->unnormalize($individual_item_to_unnormalize);
71
+	}
72 72
 }
73 73
 // End of file EE_Normalization_Strategy_Base.strategy.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -15,89 +15,89 @@  discard block
 block discarded – undo
15 15
 class EE_Int_Normalization extends EE_Normalization_Strategy_Base
16 16
 {
17 17
 
18
-    /*
18
+	/*
19 19
      * regex pattern that matches for the following:
20 20
      *      * optional negative sign
21 21
      *      * one or more digits
22 22
      */
23
-    const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
23
+	const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * @param string $value_to_normalize
29
-     * @return int|mixed|string
30
-     * @throws \EE_Validation_Error
31
-     */
32
-    public function normalize($value_to_normalize)
33
-    {
34
-        if ($value_to_normalize === null) {
35
-            return null;
36
-        }
37
-        if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
38
-            return (int)$value_to_normalize;
39
-        }
40
-        if (! is_string($value_to_normalize)) {
41
-            throw new EE_Validation_Error(
42
-                sprintf(
43
-                    __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
-                    print_r($value_to_normalize, true),
45
-                    gettype($value_to_normalize)
46
-                )
47
-            );
48
-        }
49
-        $value_to_normalize = filter_var(
50
-            $value_to_normalize,
51
-            FILTER_SANITIZE_NUMBER_FLOAT,
52
-            FILTER_FLAG_ALLOW_FRACTION
53
-        );
54
-        if ($value_to_normalize === '') {
55
-            return null;
56
-        }
57
-        $matches = array();
58
-        if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
59
-            if (count($matches) === 3) {
60
-                // if first match is the negative sign,
61
-                // then the number needs to be multiplied by -1 to remain negative
62
-                return $matches[1] === '-'
63
-                    ? (int)$matches[2] * -1
64
-                    : (int)$matches[2];
65
-            }
66
-        }
67
-        //find if this input has a int validation strategy
68
-        //in which case, use its message
69
-        $validation_error_message = null;
70
-        foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
71
-            if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
72
-                $validation_error_message = $validation_strategy->get_validation_error_message();
73
-            }
74
-        }
75
-        //this really shouldn't ever happen because fields with a int normalization strategy
76
-        //should also have a int validation strategy, but in case it doesn't use the default
77
-        if (! $validation_error_message) {
78
-            $default_validation_strategy = new EE_Int_Validation_Strategy();
79
-            $validation_error_message = $default_validation_strategy->get_validation_error_message();
80
-        }
81
-        throw new EE_Validation_Error($validation_error_message, 'numeric_only');
82
-    }
27
+	/**
28
+	 * @param string $value_to_normalize
29
+	 * @return int|mixed|string
30
+	 * @throws \EE_Validation_Error
31
+	 */
32
+	public function normalize($value_to_normalize)
33
+	{
34
+		if ($value_to_normalize === null) {
35
+			return null;
36
+		}
37
+		if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
38
+			return (int)$value_to_normalize;
39
+		}
40
+		if (! is_string($value_to_normalize)) {
41
+			throw new EE_Validation_Error(
42
+				sprintf(
43
+					__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
+					print_r($value_to_normalize, true),
45
+					gettype($value_to_normalize)
46
+				)
47
+			);
48
+		}
49
+		$value_to_normalize = filter_var(
50
+			$value_to_normalize,
51
+			FILTER_SANITIZE_NUMBER_FLOAT,
52
+			FILTER_FLAG_ALLOW_FRACTION
53
+		);
54
+		if ($value_to_normalize === '') {
55
+			return null;
56
+		}
57
+		$matches = array();
58
+		if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
59
+			if (count($matches) === 3) {
60
+				// if first match is the negative sign,
61
+				// then the number needs to be multiplied by -1 to remain negative
62
+				return $matches[1] === '-'
63
+					? (int)$matches[2] * -1
64
+					: (int)$matches[2];
65
+			}
66
+		}
67
+		//find if this input has a int validation strategy
68
+		//in which case, use its message
69
+		$validation_error_message = null;
70
+		foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
71
+			if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
72
+				$validation_error_message = $validation_strategy->get_validation_error_message();
73
+			}
74
+		}
75
+		//this really shouldn't ever happen because fields with a int normalization strategy
76
+		//should also have a int validation strategy, but in case it doesn't use the default
77
+		if (! $validation_error_message) {
78
+			$default_validation_strategy = new EE_Int_Validation_Strategy();
79
+			$validation_error_message = $default_validation_strategy->get_validation_error_message();
80
+		}
81
+		throw new EE_Validation_Error($validation_error_message, 'numeric_only');
82
+	}
83 83
 
84 84
 
85 85
 
86
-    /**
87
-     * Converts the int into a string for use in teh html form
88
-     *
89
-     * @param int $normalized_value
90
-     * @return string
91
-     */
92
-    public function unnormalize($normalized_value)
93
-    {
94
-        if ($normalized_value === null || $normalized_value === '') {
95
-            return '';
96
-        }
97
-        if (empty($normalized_value)) {
98
-            return '0';
99
-        }
100
-        return "$normalized_value";
101
-    }
86
+	/**
87
+	 * Converts the int into a string for use in teh html form
88
+	 *
89
+	 * @param int $normalized_value
90
+	 * @return string
91
+	 */
92
+	public function unnormalize($normalized_value)
93
+	{
94
+		if ($normalized_value === null || $normalized_value === '') {
95
+			return '';
96
+		}
97
+		if (empty($normalized_value)) {
98
+			return '0';
99
+		}
100
+		return "$normalized_value";
101
+	}
102 102
 }
103 103
 // End of file EE_Int_Normalization.strategy.php
Please login to merge, or discard this patch.
core/db_models/fields/EE_Post_Content_Field.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -7,133 +7,133 @@
 block discarded – undo
7 7
  */
8 8
 class EE_Post_Content_Field extends EE_Text_Field_Base
9 9
 {
10
-    static protected $_added_the_content_basic_filters = false;
10
+	static protected $_added_the_content_basic_filters = false;
11 11
 
12
-    /**
13
-     * @param string $table_column
14
-     * @param string $nicename
15
-     * @param bool   $nullable
16
-     * @param null   $default_value
17
-     */
18
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
-    {
20
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
21
-        $this->setSchemaType('object');
22
-    }
12
+	/**
13
+	 * @param string $table_column
14
+	 * @param string $nicename
15
+	 * @param bool   $nullable
16
+	 * @param null   $default_value
17
+	 */
18
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
+	{
20
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
21
+		$this->setSchemaType('object');
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * removes all tags which a WP Post wouldn't allow in its content normally
27
-     *
28
-     * @param string $value
29
-     * @return string
30
-     */
31
-    function prepare_for_set($value)
32
-    {
33
-        if (! current_user_can('unfiltered_html')) {
34
-            $value = wp_kses("$value", wp_kses_allowed_html('post'));
35
-        }
36
-        return parent::prepare_for_set($value);
37
-    }
25
+	/**
26
+	 * removes all tags which a WP Post wouldn't allow in its content normally
27
+	 *
28
+	 * @param string $value
29
+	 * @return string
30
+	 */
31
+	function prepare_for_set($value)
32
+	{
33
+		if (! current_user_can('unfiltered_html')) {
34
+			$value = wp_kses("$value", wp_kses_allowed_html('post'));
35
+		}
36
+		return parent::prepare_for_set($value);
37
+	}
38 38
 
39
-    function prepare_for_set_from_db($value_found_in_db_for_model_object)
40
-    {
41
-        return $value_found_in_db_for_model_object;
42
-    }
39
+	function prepare_for_set_from_db($value_found_in_db_for_model_object)
40
+	{
41
+		return $value_found_in_db_for_model_object;
42
+	}
43 43
 
44 44
 
45 45
 
46
-    /**
47
-     * Runs the content through `the_content`, or if prepares the content for placing in a form input
48
-     * @param string $value_on_field_to_be_outputted
49
-     * @param string   $schema possible values: 'form_input' or null (if null, will run through 'the_content')
50
-     * @return string
51
-     * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
52
-     */
53
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
54
-    {
55
-        switch($schema){
56
-            case 'form_input':
57
-                return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
58
-            case 'the_content':
46
+	/**
47
+	 * Runs the content through `the_content`, or if prepares the content for placing in a form input
48
+	 * @param string $value_on_field_to_be_outputted
49
+	 * @param string   $schema possible values: 'form_input' or null (if null, will run through 'the_content')
50
+	 * @return string
51
+	 * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
52
+	 */
53
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
54
+	{
55
+		switch($schema){
56
+			case 'form_input':
57
+				return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
58
+			case 'the_content':
59 59
 
60
-                if(doing_filter( 'the_content')){
61
-                    if( defined('WP_DEBUG') && WP_DEBUG){
62
-                        throw new EE_Error(
63
-                            sprintf(
64
-                                esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'),
65
-                                'EE_Post_Content_Field::prepare_for_pretty_echoing',
66
-                                '$schema',
67
-                                'the_content',
68
-                                'the_content_wp_core_only'
69
-                            )
70
-                        );
71
-                    } else {
72
-                        return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only');
73
-                    }
74
-                }
75
-                return apply_filters(
76
-                    'the_content',
77
-                    parent::prepare_for_pretty_echoing(
78
-                        $value_on_field_to_be_outputted,
79
-                        $schema
80
-                    )
81
-                );
82
-            case 'the_content_wp_core_only':
83
-            default:
84
-                self::_ensure_filters_setup();
85
-                return apply_filters(
86
-                    'the_content_wp_core_only',
87
-                    parent::prepare_for_pretty_echoing(
88
-                        $value_on_field_to_be_outputted,
89
-                        $schema
90
-                    )
91
-                );
92
-        }
93
-    }
60
+				if(doing_filter( 'the_content')){
61
+					if( defined('WP_DEBUG') && WP_DEBUG){
62
+						throw new EE_Error(
63
+							sprintf(
64
+								esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'),
65
+								'EE_Post_Content_Field::prepare_for_pretty_echoing',
66
+								'$schema',
67
+								'the_content',
68
+								'the_content_wp_core_only'
69
+							)
70
+						);
71
+					} else {
72
+						return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only');
73
+					}
74
+				}
75
+				return apply_filters(
76
+					'the_content',
77
+					parent::prepare_for_pretty_echoing(
78
+						$value_on_field_to_be_outputted,
79
+						$schema
80
+					)
81
+				);
82
+			case 'the_content_wp_core_only':
83
+			default:
84
+				self::_ensure_filters_setup();
85
+				return apply_filters(
86
+					'the_content_wp_core_only',
87
+					parent::prepare_for_pretty_echoing(
88
+						$value_on_field_to_be_outputted,
89
+						$schema
90
+					)
91
+				);
92
+		}
93
+	}
94 94
 
95 95
 
96 96
 
97
-    /**
98
-     * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
99
-     */
100
-    protected static function _ensure_filters_setup()
101
-    {
102
-        if( !self::$_added_the_content_basic_filters){
103
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8);
105
-            add_filter('the_content_wp_core_only', 'wptexturize', 10);
106
-            add_filter('the_content_wp_core_only', 'wpautop', 10);
107
-            add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108
-            add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
-            if(function_exists('wp_make_content_images_responsive')) {
110
-                add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
111
-            }
112
-            add_filter('the_content_wp_core_only', 'do_shortcode', 11);
113
-            add_filter('the_content_wp_core_only', 'convert_smilies', 20);
114
-            self::$_added_the_content_basic_filters = true;
115
-        }
116
-    }
97
+	/**
98
+	 * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
99
+	 */
100
+	protected static function _ensure_filters_setup()
101
+	{
102
+		if( !self::$_added_the_content_basic_filters){
103
+			add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
+			add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8);
105
+			add_filter('the_content_wp_core_only', 'wptexturize', 10);
106
+			add_filter('the_content_wp_core_only', 'wpautop', 10);
107
+			add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108
+			add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
+			if(function_exists('wp_make_content_images_responsive')) {
110
+				add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
111
+			}
112
+			add_filter('the_content_wp_core_only', 'do_shortcode', 11);
113
+			add_filter('the_content_wp_core_only', 'convert_smilies', 20);
114
+			self::$_added_the_content_basic_filters = true;
115
+		}
116
+	}
117 117
 
118 118
 
119 119
 
120
-    public function getSchemaProperties()
121
-    {
122
-        return array(
123
-            'raw' => array(
124
-                'description' =>  sprintf(
125
-                    __('%s - the content as it exists in the database.', 'event_espresso'),
126
-                    $this->get_nicename()
127
-                ),
128
-                'type' => 'string'
129
-            ),
130
-            'rendered' => array(
131
-                'description' =>  sprintf(
132
-                    __('%s - the content rendered for display.', 'event_espresso'),
133
-                    $this->get_nicename()
134
-                ),
135
-                'type' => 'string'
136
-            )
137
-        );
138
-    }
120
+	public function getSchemaProperties()
121
+	{
122
+		return array(
123
+			'raw' => array(
124
+				'description' =>  sprintf(
125
+					__('%s - the content as it exists in the database.', 'event_espresso'),
126
+					$this->get_nicename()
127
+				),
128
+				'type' => 'string'
129
+			),
130
+			'rendered' => array(
131
+				'description' =>  sprintf(
132
+					__('%s - the content rendered for display.', 'event_espresso'),
133
+					$this->get_nicename()
134
+				),
135
+				'type' => 'string'
136
+			)
137
+		);
138
+	}
139 139
 }
140 140
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     function prepare_for_set($value)
32 32
     {
33
-        if (! current_user_can('unfiltered_html')) {
33
+        if ( ! current_user_can('unfiltered_html')) {
34 34
             $value = wp_kses("$value", wp_kses_allowed_html('post'));
35 35
         }
36 36
         return parent::prepare_for_set($value);
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
54 54
     {
55
-        switch($schema){
55
+        switch ($schema) {
56 56
             case 'form_input':
57 57
                 return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
58 58
             case 'the_content':
59 59
 
60
-                if(doing_filter( 'the_content')){
61
-                    if( defined('WP_DEBUG') && WP_DEBUG){
60
+                if (doing_filter('the_content')) {
61
+                    if (defined('WP_DEBUG') && WP_DEBUG) {
62 62
                         throw new EE_Error(
63 63
                             sprintf(
64 64
                                 esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'),
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected static function _ensure_filters_setup()
101 101
     {
102
-        if( !self::$_added_the_content_basic_filters){
103
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8);
102
+        if ( ! self::$_added_the_content_basic_filters) {
103
+            add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
+            add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'autoembed'), 8);
105 105
             add_filter('the_content_wp_core_only', 'wptexturize', 10);
106 106
             add_filter('the_content_wp_core_only', 'wpautop', 10);
107 107
             add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108 108
             add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
-            if(function_exists('wp_make_content_images_responsive')) {
109
+            if (function_exists('wp_make_content_images_responsive')) {
110 110
                 add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
111 111
             }
112 112
             add_filter('the_content_wp_core_only', 'do_shortcode', 11);
Please login to merge, or discard this patch.
admin/extend/general_settings/Extend_General_Settings_Admin_Page.core.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -21,62 +21,62 @@  discard block
 block discarded – undo
21 21
 {
22 22
     
23 23
     
24
-    public function __construct($routing = true)
25
-    {
26
-        parent::__construct($routing);
27
-        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
28
-    }
24
+	public function __construct($routing = true)
25
+	{
26
+		parent::__construct($routing);
27
+		define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
28
+	}
29 29
     
30 30
     
31
-    protected function _extend_page_config()
32
-    {
31
+	protected function _extend_page_config()
32
+	{
33 33
         
34
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
34
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
35 35
         
36
-        //filters and action hooks here
37
-        add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
38
-        add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
39
-            array($this, 'update_debug_logging_options'), 10, 1);
36
+		//filters and action hooks here
37
+		add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
38
+		add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
39
+			array($this, 'update_debug_logging_options'), 10, 1);
40 40
         
41
-    }
41
+	}
42 42
     
43 43
     
44 44
     
45
-    /*************        Logging Settings        *************/
45
+	/*************        Logging Settings        *************/
46 46
     
47
-    /**
48
-     * debug_logging_options
49
-     *
50
-     * @param array $template_args
51
-     *
52
-     * @return void
53
-     */
54
-    public function debug_logging_options($template_args = array())
55
-    {
56
-        $template_args['use_full_logging']   = EE_Registry::instance()->CFG->admin->use_full_logging;
57
-        $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : false;
58
-        $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
59
-        $template                            = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
60
-        EEH_Template::display_template($template, $template_args);
61
-    }
47
+	/**
48
+	 * debug_logging_options
49
+	 *
50
+	 * @param array $template_args
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function debug_logging_options($template_args = array())
55
+	{
56
+		$template_args['use_full_logging']   = EE_Registry::instance()->CFG->admin->use_full_logging;
57
+		$template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : false;
58
+		$template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
59
+		$template                            = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
60
+		EEH_Template::display_template($template, $template_args);
61
+	}
62 62
     
63 63
     
64
-    /**
65
-     * update_debug_logging_options
66
-     *
67
-     * @param array $admin_options
68
-     *
69
-     * @return array
70
-     */
71
-    public function update_debug_logging_options($admin_options = array())
72
-    {
73
-        $use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool)absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
74
-        $admin_options->use_full_logging = $use_full_logging;
75
-        $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
76
-        $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
64
+	/**
65
+	 * update_debug_logging_options
66
+	 *
67
+	 * @param array $admin_options
68
+	 *
69
+	 * @return array
70
+	 */
71
+	public function update_debug_logging_options($admin_options = array())
72
+	{
73
+		$use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool)absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
74
+		$admin_options->use_full_logging = $use_full_logging;
75
+		$admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
76
+		$admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
77 77
         
78
-        return $admin_options;
79
-    }
78
+		return $admin_options;
79
+	}
80 80
     
81 81
     
82 82
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
     public function __construct($routing = true)
25 25
     {
26 26
         parent::__construct($routing);
27
-        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
27
+        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'general_settings/templates/');
28 28
     }
29 29
     
30 30
     
31 31
     protected function _extend_page_config()
32 32
     {
33 33
         
34
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
34
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'general_settings';
35 35
         
36 36
         //filters and action hooks here
37 37
         add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $template_args['use_full_logging']   = EE_Registry::instance()->CFG->admin->use_full_logging;
57 57
         $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : false;
58 58
         $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
59
-        $template                            = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
59
+        $template                            = GEN_SET_CAF_TEMPLATE_PATH.'debug_log_settings.template.php';
60 60
         EEH_Template::display_template($template, $template_args);
61 61
     }
62 62
     
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function update_debug_logging_options($admin_options = array())
72 72
     {
73
-        $use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool)absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
73
+        $use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
74 74
         $admin_options->use_full_logging = $use_full_logging;
75 75
         $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
76 76
         $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\exceptions\InvalidInterfaceException;
4 4
 use EventEspresso\core\services\loaders\LoaderInterface;
5 5
 
6
-if (! defined('EVENT_ESPRESSO_VERSION')) {
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7 7
     exit('No direct script access allowed');
8 8
 }
9 9
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     public static function instance(EE_Request $request = null, EE_Response $response = null)
117 117
     {
118 118
         // check if class object is instantiated, and instantiated properly
119
-        if (! self::$_instance instanceof EE_Dependency_Map) {
119
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
120 120
             self::$_instance = new EE_Dependency_Map($request, $response);
121 121
         }
122 122
         return self::$_instance;
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public static function register_dependencies($class, $dependencies)
143 143
     {
144
-        if (! isset(self::$_instance->_dependency_map[$class])) {
144
+        if ( ! isset(self::$_instance->_dependency_map[$class])) {
145 145
             // we need to make sure that any aliases used when registering a dependency
146 146
             // get resolved to the correct class name
147
-            foreach ((array)$dependencies as $dependency => $load_source) {
147
+            foreach ((array) $dependencies as $dependency => $load_source) {
148 148
                 $alias = self::$_instance->get_alias($dependency);
149 149
                 unset($dependencies[$dependency]);
150 150
                 $dependencies[$alias] = $load_source;
151 151
             }
152
-            self::$_instance->_dependency_map[$class] = (array)$dependencies;
152
+            self::$_instance->_dependency_map[$class] = (array) $dependencies;
153 153
             return true;
154 154
         }
155 155
         return false;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             );
182 182
         }
183 183
         $class_name = self::$_instance->get_alias($class_name);
184
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
184
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
185 185
             self::$_instance->_class_loaders[$class_name] = $loader;
186 186
             return true;
187 187
         }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     public function add_alias($class_name, $alias, $for_class = '')
280 280
     {
281 281
         if ($for_class !== '') {
282
-            if (! isset($this->_aliases[$for_class])) {
282
+            if ( ! isset($this->_aliases[$for_class])) {
283 283
                 $this->_aliases[$for_class] = array();
284 284
             }
285 285
             $this->_aliases[$for_class][$class_name] = $alias;
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function get_alias($class_name = '', $for_class = '')
326 326
     {
327
-        if (! $this->has_alias($class_name, $for_class)) {
327
+        if ( ! $this->has_alias($class_name, $for_class)) {
328 328
             return $class_name;
329 329
         }
330 330
         if ($for_class !== '') {
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
             'EE_Front_Controller'                  => 'load_core',
527 527
             'EE_Module_Request_Router'             => 'load_core',
528 528
             'EE_Registry'                          => 'load_core',
529
-            'EE_Request'                           => function () use (&$request) {
529
+            'EE_Request'                           => function() use (&$request) {
530 530
                 return $request;
531 531
             },
532
-            'EE_Response'                          => function () use (&$response) {
532
+            'EE_Response'                          => function() use (&$response) {
533 533
                 return $response;
534 534
             },
535 535
             'EE_Request_Handler'                   => 'load_core',
@@ -546,10 +546,10 @@  discard block
 block discarded – undo
546 546
             'EE_Messages_Queue'                    => 'load_lib',
547 547
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
548 548
             'EE_Message_Template_Group_Collection' => 'load_lib',
549
-            'EE_Messages_Generator'                => function () {
549
+            'EE_Messages_Generator'                => function() {
550 550
                 return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false);
551 551
             },
552
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
552
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
553 553
                 return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false);
554 554
             },
555 555
             //load_model
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
             'EEM_Message_Template_Group'           => 'load_model',
558 558
             'EEM_Message_Template'                 => 'load_model',
559 559
             //load_helper
560
-            'EEH_Parse_Shortcodes'                 => function () {
560
+            'EEH_Parse_Shortcodes'                 => function() {
561 561
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
562 562
                     return new EEH_Parse_Shortcodes();
563 563
                 }
564 564
                 return null;
565 565
             },
566
-            'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) {
566
+            'EventEspresso\core\services\loaders\Loader' => function() use (&$loader) {
567 567
                 return $loader;
568 568
             },
569 569
         );
Please login to merge, or discard this patch.
Indentation   +592 added lines, -592 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\loaders\LoaderInterface;
5 5
 
6 6
 if (! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -22,597 +22,597 @@  discard block
 block discarded – undo
22 22
 {
23 23
 
24 24
 
25
-    /**
26
-     * This means that the requested class dependency is not present in the dependency map
27
-     */
28
-    const not_registered = 0;
29
-
30
-
31
-    /**
32
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
33
-     */
34
-    const load_new_object = 1;
35
-
36
-    /**
37
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
38
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
39
-     */
40
-    const load_from_cache = 2;
41
-
42
-    /**
43
-     * @type EE_Dependency_Map $_instance
44
-     */
45
-    protected static $_instance;
46
-
47
-    /**
48
-     * @type EE_Request $request
49
-     */
50
-    protected $_request;
51
-
52
-    /**
53
-     * @type EE_Response $response
54
-     */
55
-    protected $_response;
56
-
57
-    /**
58
-     * @type LoaderInterface $loader
59
-     */
60
-    protected $loader;
61
-
62
-    /**
63
-     * @type array $_dependency_map
64
-     */
65
-    protected $_dependency_map = array();
66
-
67
-    /**
68
-     * @type array $_class_loaders
69
-     */
70
-    protected $_class_loaders = array();
71
-
72
-    /**
73
-     * @type array $_aliases
74
-     */
75
-    protected $_aliases = array();
76
-
77
-
78
-
79
-    /**
80
-     * EE_Dependency_Map constructor.
81
-     *
82
-     * @param EE_Request  $request
83
-     * @param EE_Response $response
84
-     */
85
-    protected function __construct(EE_Request $request, EE_Response $response)
86
-    {
87
-        $this->_request = $request;
88
-        $this->_response = $response;
89
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
90
-        do_action('EE_Dependency_Map____construct');
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * @throws InvalidDataTypeException
97
-     * @throws InvalidInterfaceException
98
-     * @throws InvalidArgumentException
99
-     */
100
-    public function initialize()
101
-    {
102
-        $this->_register_core_dependencies();
103
-        $this->_register_core_class_loaders();
104
-        $this->_register_core_aliases();
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @singleton method used to instantiate class object
111
-     * @access    public
112
-     * @param EE_Request  $request
113
-     * @param EE_Response $response
114
-     * @return EE_Dependency_Map
115
-     */
116
-    public static function instance(EE_Request $request = null, EE_Response $response = null)
117
-    {
118
-        // check if class object is instantiated, and instantiated properly
119
-        if (! self::$_instance instanceof EE_Dependency_Map) {
120
-            self::$_instance = new EE_Dependency_Map($request, $response);
121
-        }
122
-        return self::$_instance;
123
-    }
124
-
125
-
126
-
127
-    /**
128
-     * @param LoaderInterface $loader
129
-     */
130
-    public function setLoader(LoaderInterface $loader)
131
-    {
132
-        $this->loader = $loader;
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     * @param string $class
139
-     * @param array  $dependencies
140
-     * @return boolean
141
-     */
142
-    public static function register_dependencies($class, $dependencies)
143
-    {
144
-        if (! isset(self::$_instance->_dependency_map[$class])) {
145
-            // we need to make sure that any aliases used when registering a dependency
146
-            // get resolved to the correct class name
147
-            foreach ((array)$dependencies as $dependency => $load_source) {
148
-                $alias = self::$_instance->get_alias($dependency);
149
-                unset($dependencies[$dependency]);
150
-                $dependencies[$alias] = $load_source;
151
-            }
152
-            self::$_instance->_dependency_map[$class] = (array)$dependencies;
153
-            return true;
154
-        }
155
-        return false;
156
-    }
157
-
158
-
159
-
160
-    /**
161
-     * @param string $class_name
162
-     * @param string $loader
163
-     * @return bool
164
-     * @throws EE_Error
165
-     */
166
-    public static function register_class_loader($class_name, $loader = 'load_core')
167
-    {
168
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
169
-        if (
170
-            ! is_callable($loader)
171
-            && (
172
-                strpos($loader, 'load_') !== 0
173
-                || ! method_exists('EE_Registry', $loader)
174
-            )
175
-        ) {
176
-            throw new EE_Error(
177
-                sprintf(
178
-                    esc_html__('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'),
179
-                    $loader
180
-                )
181
-            );
182
-        }
183
-        $class_name = self::$_instance->get_alias($class_name);
184
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
185
-            self::$_instance->_class_loaders[$class_name] = $loader;
186
-            return true;
187
-        }
188
-        return false;
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * @return array
195
-     */
196
-    public function dependency_map()
197
-    {
198
-        return $this->_dependency_map;
199
-    }
200
-
201
-
202
-
203
-    /**
204
-     * returns TRUE if dependency map contains a listing for the provided class name
205
-     *
206
-     * @param string $class_name
207
-     * @return boolean
208
-     */
209
-    public function has($class_name = '')
210
-    {
211
-        return isset($this->_dependency_map[$class_name]) ? true : false;
212
-    }
213
-
214
-
215
-
216
-    /**
217
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
218
-     *
219
-     * @param string $class_name
220
-     * @param string $dependency
221
-     * @return bool
222
-     */
223
-    public function has_dependency_for_class($class_name = '', $dependency = '')
224
-    {
225
-        $dependency = $this->get_alias($dependency);
226
-        return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
227
-            ? true
228
-            : false;
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
235
-     *
236
-     * @param string $class_name
237
-     * @param string $dependency
238
-     * @return int
239
-     */
240
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
241
-    {
242
-        $dependency = $this->get_alias($dependency);
243
-        return $this->has_dependency_for_class($class_name, $dependency)
244
-            ? $this->_dependency_map[$class_name][$dependency]
245
-            : EE_Dependency_Map::not_registered;
246
-    }
247
-
248
-
249
-
250
-    /**
251
-     * @param string $class_name
252
-     * @return string | Closure
253
-     */
254
-    public function class_loader($class_name)
255
-    {
256
-        $class_name = $this->get_alias($class_name);
257
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
258
-    }
259
-
260
-
261
-
262
-    /**
263
-     * @return array
264
-     */
265
-    public function class_loaders()
266
-    {
267
-        return $this->_class_loaders;
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * adds an alias for a classname
274
-     *
275
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
276
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
277
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
278
-     */
279
-    public function add_alias($class_name, $alias, $for_class = '')
280
-    {
281
-        if ($for_class !== '') {
282
-            if (! isset($this->_aliases[$for_class])) {
283
-                $this->_aliases[$for_class] = array();
284
-            }
285
-            $this->_aliases[$for_class][$class_name] = $alias;
286
-        }
287
-        $this->_aliases[$class_name] = $alias;
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * returns TRUE if the provided class name has an alias
294
-     *
295
-     * @param string $class_name
296
-     * @param string $for_class
297
-     * @return bool
298
-     */
299
-    public function has_alias($class_name = '', $for_class = '')
300
-    {
301
-        return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
302
-               || (
303
-                   isset($this->_aliases[$class_name])
304
-                   && ! is_array($this->_aliases[$class_name])
305
-               );
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * returns alias for class name if one exists, otherwise returns the original classname
312
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
313
-     *  for example:
314
-     *      if the following two entries were added to the _aliases array:
315
-     *          array(
316
-     *              'interface_alias'           => 'some\namespace\interface'
317
-     *              'some\namespace\interface'  => 'some\namespace\classname'
318
-     *          )
319
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
320
-     *      to load an instance of 'some\namespace\classname'
321
-     *
322
-     * @param string $class_name
323
-     * @param string $for_class
324
-     * @return string
325
-     */
326
-    public function get_alias($class_name = '', $for_class = '')
327
-    {
328
-        if (! $this->has_alias($class_name, $for_class)) {
329
-            return $class_name;
330
-        }
331
-        if ($for_class !== '') {
332
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
333
-        }
334
-        return $this->get_alias($this->_aliases[$class_name]);
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
341
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
342
-     * This is done by using the following class constants:
343
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
344
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
345
-     */
346
-    protected function _register_core_dependencies()
347
-    {
348
-        $this->_dependency_map = array(
349
-            'EE_Request_Handler'                                                                                          => array(
350
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
351
-            ),
352
-            'EE_System'                                                                                                   => array(
353
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
354
-            ),
355
-            'EE_Session'                                                                                                  => array(
356
-                'EE_Encryption' => EE_Dependency_Map::load_from_cache,
357
-            ),
358
-            'EE_Cart'                                                                                                     => array(
359
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
360
-            ),
361
-            'EE_Front_Controller'                                                                                         => array(
362
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
363
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
364
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
365
-            ),
366
-            'EE_Messenger_Collection_Loader'                                                                              => array(
367
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
368
-            ),
369
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
370
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
371
-            ),
372
-            'EE_Message_Resource_Manager'                                                                                 => array(
373
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
374
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
375
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
376
-            ),
377
-            'EE_Message_Factory'                                                                                          => array(
378
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
379
-            ),
380
-            'EE_messages'                                                                                                 => array(
381
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
382
-            ),
383
-            'EE_Messages_Generator'                                                                                       => array(
384
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
385
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
386
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
387
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
388
-            ),
389
-            'EE_Messages_Processor'                                                                                       => array(
390
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
391
-            ),
392
-            'EE_Messages_Queue'                                                                                           => array(
393
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
394
-            ),
395
-            'EE_Messages_Template_Defaults'                                                                               => array(
396
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
397
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
398
-            ),
399
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
400
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
401
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
402
-            ),
403
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
404
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
405
-            ),
406
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
407
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
408
-            ),
409
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                              => array(
410
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
411
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
412
-            ),
413
-            'EventEspresso\core\services\commands\CommandFactory'                                                              => array(
414
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
415
-            ),
416
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
417
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
418
-            ),
419
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
420
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
421
-            ),
422
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
423
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
424
-            ),
425
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
426
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
427
-            ),
428
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
429
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
430
-            ),
431
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
432
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
433
-            ),
434
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
435
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
436
-            ),
437
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
438
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
439
-            ),
440
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
441
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
442
-            ),
443
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
444
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
445
-            ),
446
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
447
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
450
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
451
-            ),
452
-            'EE_Data_Migration_Class_Base'                                                                                => array(
453
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
454
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
455
-            ),
456
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
457
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
459
-            ),
460
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
461
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
462
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
463
-            ),
464
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
465
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
466
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
467
-            ),
468
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
469
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
471
-            ),
472
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
473
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
474
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
475
-            ),
476
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
477
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
478
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
481
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
482
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
485
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
486
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
489
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
490
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
491
-            ),
492
-        );
493
-    }
494
-
495
-
496
-
497
-    /**
498
-     * Registers how core classes are loaded.
499
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
500
-     *        'EE_Request_Handler' => 'load_core'
501
-     *        'EE_Messages_Queue'  => 'load_lib'
502
-     *        'EEH_Debug_Tools'    => 'load_helper'
503
-     * or, if greater control is required, by providing a custom closure. For example:
504
-     *        'Some_Class' => function () {
505
-     *            return new Some_Class();
506
-     *        },
507
-     * This is required for instantiating dependencies
508
-     * where an interface has been type hinted in a class constructor. For example:
509
-     *        'Required_Interface' => function () {
510
-     *            return new A_Class_That_Implements_Required_Interface();
511
-     *        },
512
-     */
513
-    protected function _register_core_class_loaders()
514
-    {
515
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
516
-        //be used in a closure.
517
-        $request = &$this->_request;
518
-        $response = &$this->_response;
519
-        $loader = &$this->loader;
520
-        $this->_class_loaders = array(
521
-            //load_core
522
-            'EE_Capabilities'                      => 'load_core',
523
-            'EE_Encryption'                        => 'load_core',
524
-            'EE_Front_Controller'                  => 'load_core',
525
-            'EE_Module_Request_Router'             => 'load_core',
526
-            'EE_Registry'                          => 'load_core',
527
-            'EE_Request'                           => function () use (&$request) {
528
-                return $request;
529
-            },
530
-            'EE_Response'                          => function () use (&$response) {
531
-                return $response;
532
-            },
533
-            'EE_Request_Handler'                   => 'load_core',
534
-            'EE_Session'                           => 'load_core',
535
-            'EE_System'                            => 'load_core',
536
-            //load_lib
537
-            'EE_Message_Resource_Manager'          => 'load_lib',
538
-            'EE_Message_Type_Collection'           => 'load_lib',
539
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
540
-            'EE_Messenger_Collection'              => 'load_lib',
541
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
542
-            'EE_Messages_Processor'                => 'load_lib',
543
-            'EE_Message_Repository'                => 'load_lib',
544
-            'EE_Messages_Queue'                    => 'load_lib',
545
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
546
-            'EE_Message_Template_Group_Collection' => 'load_lib',
547
-            'EE_Messages_Generator'                => function () {
548
-                return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false);
549
-            },
550
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
551
-                return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false);
552
-            },
553
-            //load_model
554
-            'EEM_Message_Template_Group'           => 'load_model',
555
-            'EEM_Message_Template'                 => 'load_model',
556
-            //load_helper
557
-            'EEH_Parse_Shortcodes'                 => function () {
558
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
559
-                    return new EEH_Parse_Shortcodes();
560
-                }
561
-                return null;
562
-            },
563
-            'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) {
564
-                return $loader;
565
-            },
566
-        );
567
-    }
568
-
569
-
570
-
571
-    /**
572
-     * can be used for supplying alternate names for classes,
573
-     * or for connecting interface names to instantiable classes
574
-     */
575
-    protected function _register_core_aliases()
576
-    {
577
-        $this->_aliases = array(
578
-            'CommandBusInterface'                                                 => 'EventEspresso\core\services\commands\CommandBusInterface',
579
-            'EventEspresso\core\services\commands\CommandBusInterface'            => 'EventEspresso\core\services\commands\CommandBus',
580
-            'CommandHandlerManagerInterface'                                      => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
581
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager',
582
-            'CapChecker'                                                          => 'EventEspresso\core\services\commands\middleware\CapChecker',
583
-            'AddActionHook'                                                       => 'EventEspresso\core\services\commands\middleware\AddActionHook',
584
-            'CapabilitiesChecker'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
585
-            'CapabilitiesCheckerInterface'                                        => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
586
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
587
-            'CreateRegistrationService'                                           => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
588
-            'CreateRegCodeCommandHandler'                                         => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
589
-            'CreateRegUrlLinkCommandHandler'                                      => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
590
-            'CreateRegistrationCommandHandler'                                    => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
591
-            'CopyRegistrationDetailsCommandHandler'                               => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
592
-            'CopyRegistrationPaymentsCommandHandler'                              => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
593
-            'CancelRegistrationAndTicketLineItemCommandHandler'                   => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
594
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'           => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
595
-            'CreateTicketLineItemCommandHandler'                                  => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
596
-            'TableManager'                                                        => 'EventEspresso\core\services\database\TableManager',
597
-            'TableAnalysis'                                                       => 'EventEspresso\core\services\database\TableAnalysis',
598
-            'LoaderInterface'                                                     => 'EventEspresso\core\services\loaders\LoaderInterface',
599
-            'EventEspresso\core\services\loaders\LoaderInterface'                 => 'EventEspresso\core\services\loaders\Loader',
600
-            'CommandFactoryInterface'                                             => 'EventEspresso\core\services\commands\CommandFactoryInterface',
601
-            'EventEspresso\core\services\commands\CommandFactoryInterface'        => 'EventEspresso\core\services\commands\CommandFactory',
602
-        );
603
-    }
604
-
605
-
606
-
607
-    /**
608
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
609
-     * request Primarily used by unit tests.
610
-     */
611
-    public function reset()
612
-    {
613
-        $this->_register_core_class_loaders();
614
-        $this->_register_core_dependencies();
615
-    }
25
+	/**
26
+	 * This means that the requested class dependency is not present in the dependency map
27
+	 */
28
+	const not_registered = 0;
29
+
30
+
31
+	/**
32
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
33
+	 */
34
+	const load_new_object = 1;
35
+
36
+	/**
37
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
38
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
39
+	 */
40
+	const load_from_cache = 2;
41
+
42
+	/**
43
+	 * @type EE_Dependency_Map $_instance
44
+	 */
45
+	protected static $_instance;
46
+
47
+	/**
48
+	 * @type EE_Request $request
49
+	 */
50
+	protected $_request;
51
+
52
+	/**
53
+	 * @type EE_Response $response
54
+	 */
55
+	protected $_response;
56
+
57
+	/**
58
+	 * @type LoaderInterface $loader
59
+	 */
60
+	protected $loader;
61
+
62
+	/**
63
+	 * @type array $_dependency_map
64
+	 */
65
+	protected $_dependency_map = array();
66
+
67
+	/**
68
+	 * @type array $_class_loaders
69
+	 */
70
+	protected $_class_loaders = array();
71
+
72
+	/**
73
+	 * @type array $_aliases
74
+	 */
75
+	protected $_aliases = array();
76
+
77
+
78
+
79
+	/**
80
+	 * EE_Dependency_Map constructor.
81
+	 *
82
+	 * @param EE_Request  $request
83
+	 * @param EE_Response $response
84
+	 */
85
+	protected function __construct(EE_Request $request, EE_Response $response)
86
+	{
87
+		$this->_request = $request;
88
+		$this->_response = $response;
89
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
90
+		do_action('EE_Dependency_Map____construct');
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * @throws InvalidDataTypeException
97
+	 * @throws InvalidInterfaceException
98
+	 * @throws InvalidArgumentException
99
+	 */
100
+	public function initialize()
101
+	{
102
+		$this->_register_core_dependencies();
103
+		$this->_register_core_class_loaders();
104
+		$this->_register_core_aliases();
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @singleton method used to instantiate class object
111
+	 * @access    public
112
+	 * @param EE_Request  $request
113
+	 * @param EE_Response $response
114
+	 * @return EE_Dependency_Map
115
+	 */
116
+	public static function instance(EE_Request $request = null, EE_Response $response = null)
117
+	{
118
+		// check if class object is instantiated, and instantiated properly
119
+		if (! self::$_instance instanceof EE_Dependency_Map) {
120
+			self::$_instance = new EE_Dependency_Map($request, $response);
121
+		}
122
+		return self::$_instance;
123
+	}
124
+
125
+
126
+
127
+	/**
128
+	 * @param LoaderInterface $loader
129
+	 */
130
+	public function setLoader(LoaderInterface $loader)
131
+	{
132
+		$this->loader = $loader;
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 * @param string $class
139
+	 * @param array  $dependencies
140
+	 * @return boolean
141
+	 */
142
+	public static function register_dependencies($class, $dependencies)
143
+	{
144
+		if (! isset(self::$_instance->_dependency_map[$class])) {
145
+			// we need to make sure that any aliases used when registering a dependency
146
+			// get resolved to the correct class name
147
+			foreach ((array)$dependencies as $dependency => $load_source) {
148
+				$alias = self::$_instance->get_alias($dependency);
149
+				unset($dependencies[$dependency]);
150
+				$dependencies[$alias] = $load_source;
151
+			}
152
+			self::$_instance->_dependency_map[$class] = (array)$dependencies;
153
+			return true;
154
+		}
155
+		return false;
156
+	}
157
+
158
+
159
+
160
+	/**
161
+	 * @param string $class_name
162
+	 * @param string $loader
163
+	 * @return bool
164
+	 * @throws EE_Error
165
+	 */
166
+	public static function register_class_loader($class_name, $loader = 'load_core')
167
+	{
168
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
169
+		if (
170
+			! is_callable($loader)
171
+			&& (
172
+				strpos($loader, 'load_') !== 0
173
+				|| ! method_exists('EE_Registry', $loader)
174
+			)
175
+		) {
176
+			throw new EE_Error(
177
+				sprintf(
178
+					esc_html__('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'),
179
+					$loader
180
+				)
181
+			);
182
+		}
183
+		$class_name = self::$_instance->get_alias($class_name);
184
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
185
+			self::$_instance->_class_loaders[$class_name] = $loader;
186
+			return true;
187
+		}
188
+		return false;
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * @return array
195
+	 */
196
+	public function dependency_map()
197
+	{
198
+		return $this->_dependency_map;
199
+	}
200
+
201
+
202
+
203
+	/**
204
+	 * returns TRUE if dependency map contains a listing for the provided class name
205
+	 *
206
+	 * @param string $class_name
207
+	 * @return boolean
208
+	 */
209
+	public function has($class_name = '')
210
+	{
211
+		return isset($this->_dependency_map[$class_name]) ? true : false;
212
+	}
213
+
214
+
215
+
216
+	/**
217
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
218
+	 *
219
+	 * @param string $class_name
220
+	 * @param string $dependency
221
+	 * @return bool
222
+	 */
223
+	public function has_dependency_for_class($class_name = '', $dependency = '')
224
+	{
225
+		$dependency = $this->get_alias($dependency);
226
+		return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
227
+			? true
228
+			: false;
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
235
+	 *
236
+	 * @param string $class_name
237
+	 * @param string $dependency
238
+	 * @return int
239
+	 */
240
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
241
+	{
242
+		$dependency = $this->get_alias($dependency);
243
+		return $this->has_dependency_for_class($class_name, $dependency)
244
+			? $this->_dependency_map[$class_name][$dependency]
245
+			: EE_Dependency_Map::not_registered;
246
+	}
247
+
248
+
249
+
250
+	/**
251
+	 * @param string $class_name
252
+	 * @return string | Closure
253
+	 */
254
+	public function class_loader($class_name)
255
+	{
256
+		$class_name = $this->get_alias($class_name);
257
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
258
+	}
259
+
260
+
261
+
262
+	/**
263
+	 * @return array
264
+	 */
265
+	public function class_loaders()
266
+	{
267
+		return $this->_class_loaders;
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * adds an alias for a classname
274
+	 *
275
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
276
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
277
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
278
+	 */
279
+	public function add_alias($class_name, $alias, $for_class = '')
280
+	{
281
+		if ($for_class !== '') {
282
+			if (! isset($this->_aliases[$for_class])) {
283
+				$this->_aliases[$for_class] = array();
284
+			}
285
+			$this->_aliases[$for_class][$class_name] = $alias;
286
+		}
287
+		$this->_aliases[$class_name] = $alias;
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * returns TRUE if the provided class name has an alias
294
+	 *
295
+	 * @param string $class_name
296
+	 * @param string $for_class
297
+	 * @return bool
298
+	 */
299
+	public function has_alias($class_name = '', $for_class = '')
300
+	{
301
+		return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
302
+			   || (
303
+				   isset($this->_aliases[$class_name])
304
+				   && ! is_array($this->_aliases[$class_name])
305
+			   );
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * returns alias for class name if one exists, otherwise returns the original classname
312
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
313
+	 *  for example:
314
+	 *      if the following two entries were added to the _aliases array:
315
+	 *          array(
316
+	 *              'interface_alias'           => 'some\namespace\interface'
317
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
318
+	 *          )
319
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
320
+	 *      to load an instance of 'some\namespace\classname'
321
+	 *
322
+	 * @param string $class_name
323
+	 * @param string $for_class
324
+	 * @return string
325
+	 */
326
+	public function get_alias($class_name = '', $for_class = '')
327
+	{
328
+		if (! $this->has_alias($class_name, $for_class)) {
329
+			return $class_name;
330
+		}
331
+		if ($for_class !== '') {
332
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
333
+		}
334
+		return $this->get_alias($this->_aliases[$class_name]);
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
341
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
342
+	 * This is done by using the following class constants:
343
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
344
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
345
+	 */
346
+	protected function _register_core_dependencies()
347
+	{
348
+		$this->_dependency_map = array(
349
+			'EE_Request_Handler'                                                                                          => array(
350
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
351
+			),
352
+			'EE_System'                                                                                                   => array(
353
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
354
+			),
355
+			'EE_Session'                                                                                                  => array(
356
+				'EE_Encryption' => EE_Dependency_Map::load_from_cache,
357
+			),
358
+			'EE_Cart'                                                                                                     => array(
359
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
360
+			),
361
+			'EE_Front_Controller'                                                                                         => array(
362
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
363
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
364
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
365
+			),
366
+			'EE_Messenger_Collection_Loader'                                                                              => array(
367
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
368
+			),
369
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
370
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
371
+			),
372
+			'EE_Message_Resource_Manager'                                                                                 => array(
373
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
374
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
375
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
376
+			),
377
+			'EE_Message_Factory'                                                                                          => array(
378
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
379
+			),
380
+			'EE_messages'                                                                                                 => array(
381
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
382
+			),
383
+			'EE_Messages_Generator'                                                                                       => array(
384
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
385
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
386
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
387
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
388
+			),
389
+			'EE_Messages_Processor'                                                                                       => array(
390
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
391
+			),
392
+			'EE_Messages_Queue'                                                                                           => array(
393
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
394
+			),
395
+			'EE_Messages_Template_Defaults'                                                                               => array(
396
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
397
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
398
+			),
399
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
400
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
401
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
402
+			),
403
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
404
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
405
+			),
406
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
407
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
408
+			),
409
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                              => array(
410
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
411
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
412
+			),
413
+			'EventEspresso\core\services\commands\CommandFactory'                                                              => array(
414
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
415
+			),
416
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
417
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
418
+			),
419
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
420
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
421
+			),
422
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
423
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
424
+			),
425
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
426
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
427
+			),
428
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
429
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
430
+			),
431
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
432
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
433
+			),
434
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
435
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
436
+			),
437
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
438
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
439
+			),
440
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
441
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
442
+			),
443
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
444
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
445
+			),
446
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
447
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
450
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
451
+			),
452
+			'EE_Data_Migration_Class_Base'                                                                                => array(
453
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
454
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
455
+			),
456
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
457
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
459
+			),
460
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
461
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
462
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
463
+			),
464
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
465
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
466
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
467
+			),
468
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
469
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
471
+			),
472
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
473
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
474
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
475
+			),
476
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
477
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
478
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
481
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
482
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
485
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
486
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
489
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
490
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
491
+			),
492
+		);
493
+	}
494
+
495
+
496
+
497
+	/**
498
+	 * Registers how core classes are loaded.
499
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
500
+	 *        'EE_Request_Handler' => 'load_core'
501
+	 *        'EE_Messages_Queue'  => 'load_lib'
502
+	 *        'EEH_Debug_Tools'    => 'load_helper'
503
+	 * or, if greater control is required, by providing a custom closure. For example:
504
+	 *        'Some_Class' => function () {
505
+	 *            return new Some_Class();
506
+	 *        },
507
+	 * This is required for instantiating dependencies
508
+	 * where an interface has been type hinted in a class constructor. For example:
509
+	 *        'Required_Interface' => function () {
510
+	 *            return new A_Class_That_Implements_Required_Interface();
511
+	 *        },
512
+	 */
513
+	protected function _register_core_class_loaders()
514
+	{
515
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
516
+		//be used in a closure.
517
+		$request = &$this->_request;
518
+		$response = &$this->_response;
519
+		$loader = &$this->loader;
520
+		$this->_class_loaders = array(
521
+			//load_core
522
+			'EE_Capabilities'                      => 'load_core',
523
+			'EE_Encryption'                        => 'load_core',
524
+			'EE_Front_Controller'                  => 'load_core',
525
+			'EE_Module_Request_Router'             => 'load_core',
526
+			'EE_Registry'                          => 'load_core',
527
+			'EE_Request'                           => function () use (&$request) {
528
+				return $request;
529
+			},
530
+			'EE_Response'                          => function () use (&$response) {
531
+				return $response;
532
+			},
533
+			'EE_Request_Handler'                   => 'load_core',
534
+			'EE_Session'                           => 'load_core',
535
+			'EE_System'                            => 'load_core',
536
+			//load_lib
537
+			'EE_Message_Resource_Manager'          => 'load_lib',
538
+			'EE_Message_Type_Collection'           => 'load_lib',
539
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
540
+			'EE_Messenger_Collection'              => 'load_lib',
541
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
542
+			'EE_Messages_Processor'                => 'load_lib',
543
+			'EE_Message_Repository'                => 'load_lib',
544
+			'EE_Messages_Queue'                    => 'load_lib',
545
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
546
+			'EE_Message_Template_Group_Collection' => 'load_lib',
547
+			'EE_Messages_Generator'                => function () {
548
+				return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false);
549
+			},
550
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
551
+				return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false);
552
+			},
553
+			//load_model
554
+			'EEM_Message_Template_Group'           => 'load_model',
555
+			'EEM_Message_Template'                 => 'load_model',
556
+			//load_helper
557
+			'EEH_Parse_Shortcodes'                 => function () {
558
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
559
+					return new EEH_Parse_Shortcodes();
560
+				}
561
+				return null;
562
+			},
563
+			'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) {
564
+				return $loader;
565
+			},
566
+		);
567
+	}
568
+
569
+
570
+
571
+	/**
572
+	 * can be used for supplying alternate names for classes,
573
+	 * or for connecting interface names to instantiable classes
574
+	 */
575
+	protected function _register_core_aliases()
576
+	{
577
+		$this->_aliases = array(
578
+			'CommandBusInterface'                                                 => 'EventEspresso\core\services\commands\CommandBusInterface',
579
+			'EventEspresso\core\services\commands\CommandBusInterface'            => 'EventEspresso\core\services\commands\CommandBus',
580
+			'CommandHandlerManagerInterface'                                      => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
581
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager',
582
+			'CapChecker'                                                          => 'EventEspresso\core\services\commands\middleware\CapChecker',
583
+			'AddActionHook'                                                       => 'EventEspresso\core\services\commands\middleware\AddActionHook',
584
+			'CapabilitiesChecker'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
585
+			'CapabilitiesCheckerInterface'                                        => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
586
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
587
+			'CreateRegistrationService'                                           => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
588
+			'CreateRegCodeCommandHandler'                                         => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
589
+			'CreateRegUrlLinkCommandHandler'                                      => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
590
+			'CreateRegistrationCommandHandler'                                    => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
591
+			'CopyRegistrationDetailsCommandHandler'                               => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
592
+			'CopyRegistrationPaymentsCommandHandler'                              => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
593
+			'CancelRegistrationAndTicketLineItemCommandHandler'                   => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
594
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'           => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
595
+			'CreateTicketLineItemCommandHandler'                                  => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
596
+			'TableManager'                                                        => 'EventEspresso\core\services\database\TableManager',
597
+			'TableAnalysis'                                                       => 'EventEspresso\core\services\database\TableAnalysis',
598
+			'LoaderInterface'                                                     => 'EventEspresso\core\services\loaders\LoaderInterface',
599
+			'EventEspresso\core\services\loaders\LoaderInterface'                 => 'EventEspresso\core\services\loaders\Loader',
600
+			'CommandFactoryInterface'                                             => 'EventEspresso\core\services\commands\CommandFactoryInterface',
601
+			'EventEspresso\core\services\commands\CommandFactoryInterface'        => 'EventEspresso\core\services\commands\CommandFactory',
602
+		);
603
+	}
604
+
605
+
606
+
607
+	/**
608
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
609
+	 * request Primarily used by unit tests.
610
+	 */
611
+	public function reset()
612
+	{
613
+		$this->_register_core_class_loaders();
614
+		$this->_register_core_dependencies();
615
+	}
616 616
 
617 617
 
618 618
 }
Please login to merge, or discard this patch.
core/services/collections/LooseCollection.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\exceptions\InvalidEntityException;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -22,40 +22,40 @@  discard block
 block discarded – undo
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * setCollectionInterface
27
-     *
28
-     * @access protected
29
-     * @param  string $collection_interface
30
-     */
31
-    protected function setCollectionInterface($collection_interface )
32
-    {
33
-        $this->collection_interface = '';
34
-    }
25
+	/**
26
+	 * setCollectionInterface
27
+	 *
28
+	 * @access protected
29
+	 * @param  string $collection_interface
30
+	 */
31
+	protected function setCollectionInterface($collection_interface )
32
+	{
33
+		$this->collection_interface = '';
34
+	}
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * add
40
-     * attaches an object to the Collection
41
-     * and sets any supplied data associated with the current iterator entry
42
-     * by calling EE_Object_Collection::set_identifier()
43
-     *
44
-     * @access public
45
-     * @param  mixed $object
46
-     * @param  mixed $identifier
47
-     * @return bool
48
-     * @throws InvalidEntityException
49
-     */
50
-    public function add($object, $identifier = null)
51
-    {
52
-        if (! is_object($object)) {
53
-            throw new InvalidEntityException($object, 'object');
54
-        }
55
-        $this->attach($object);
56
-        $this->setIdentifier($object, $identifier);
57
-        return $this->contains($object);
58
-    }
38
+	/**
39
+	 * add
40
+	 * attaches an object to the Collection
41
+	 * and sets any supplied data associated with the current iterator entry
42
+	 * by calling EE_Object_Collection::set_identifier()
43
+	 *
44
+	 * @access public
45
+	 * @param  mixed $object
46
+	 * @param  mixed $identifier
47
+	 * @return bool
48
+	 * @throws InvalidEntityException
49
+	 */
50
+	public function add($object, $identifier = null)
51
+	{
52
+		if (! is_object($object)) {
53
+			throw new InvalidEntityException($object, 'object');
54
+		}
55
+		$this->attach($object);
56
+		$this->setIdentifier($object, $identifier);
57
+		return $this->contains($object);
58
+	}
59 59
 
60 60
 
61 61
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @access protected
29 29
      * @param  string $collection_interface
30 30
      */
31
-    protected function setCollectionInterface($collection_interface )
31
+    protected function setCollectionInterface($collection_interface)
32 32
     {
33 33
         $this->collection_interface = '';
34 34
     }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function add($object, $identifier = null)
51 51
     {
52
-        if (! is_object($object)) {
52
+        if ( ! is_object($object)) {
53 53
             throw new InvalidEntityException($object, 'object');
54 54
         }
55 55
         $this->attach($object);
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.007');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.007');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.