@@ -12,40 +12,40 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_File_Normalization extends EE_Normalization_Strategy_Base |
14 | 14 | { |
15 | - /** |
|
16 | - * Keep in mind $value_to_normalize should be a FileSubmissionInterface or null, so this shouldn't really do |
|
17 | - * much (other than NOT convert it to a string or something). |
|
18 | - * @param string $value_to_normalize |
|
19 | - * @return FileSubmissionInterface |
|
20 | - */ |
|
21 | - public function normalize($value_to_normalize) |
|
22 | - { |
|
23 | - if ($value_to_normalize instanceof FileSubmissionInterface || is_null($value_to_normalize)) { |
|
24 | - return $value_to_normalize; |
|
25 | - } else { |
|
26 | - throw new EE_Validation_Error( |
|
27 | - esc_html__('The file input has an invalid format.', 'event_espresso') |
|
28 | - ); |
|
29 | - } |
|
30 | - } |
|
15 | + /** |
|
16 | + * Keep in mind $value_to_normalize should be a FileSubmissionInterface or null, so this shouldn't really do |
|
17 | + * much (other than NOT convert it to a string or something). |
|
18 | + * @param string $value_to_normalize |
|
19 | + * @return FileSubmissionInterface |
|
20 | + */ |
|
21 | + public function normalize($value_to_normalize) |
|
22 | + { |
|
23 | + if ($value_to_normalize instanceof FileSubmissionInterface || is_null($value_to_normalize)) { |
|
24 | + return $value_to_normalize; |
|
25 | + } else { |
|
26 | + throw new EE_Validation_Error( |
|
27 | + esc_html__('The file input has an invalid format.', 'event_espresso') |
|
28 | + ); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * This may be called prematurely on submitted data, so we actually don't want to convert it into a string because |
|
35 | - * we'll lose all the FileSubmissionInterface data. So prefer to leave it alone. FileSubmissionInterface |
|
36 | - * can be cast to a string just fine so it's good as-is. |
|
37 | - * |
|
38 | - * @param string $normalized_value |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function unnormalize($normalized_value) |
|
42 | - { |
|
43 | - if ($normalized_value instanceof FileSubmissionInterface || is_null($normalized_value)) { |
|
44 | - // Leave it as the object, it can be treated like a string because it |
|
45 | - // overrides __toString() |
|
46 | - return $normalized_value; |
|
47 | - } else { |
|
48 | - return (string) $normalized_value; |
|
49 | - } |
|
50 | - } |
|
33 | + /** |
|
34 | + * This may be called prematurely on submitted data, so we actually don't want to convert it into a string because |
|
35 | + * we'll lose all the FileSubmissionInterface data. So prefer to leave it alone. FileSubmissionInterface |
|
36 | + * can be cast to a string just fine so it's good as-is. |
|
37 | + * |
|
38 | + * @param string $normalized_value |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function unnormalize($normalized_value) |
|
42 | + { |
|
43 | + if ($normalized_value instanceof FileSubmissionInterface || is_null($normalized_value)) { |
|
44 | + // Leave it as the object, it can be treated like a string because it |
|
45 | + // overrides __toString() |
|
46 | + return $normalized_value; |
|
47 | + } else { |
|
48 | + return (string) $normalized_value; |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |
@@ -11,26 +11,26 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_All_Caps_Normalization extends EE_Normalization_Strategy_Base |
13 | 13 | { |
14 | - /** |
|
15 | - * @param string $value_to_normalize |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function normalize($value_to_normalize) |
|
19 | - { |
|
20 | - return strtoupper($value_to_normalize); |
|
21 | - } |
|
14 | + /** |
|
15 | + * @param string $value_to_normalize |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function normalize($value_to_normalize) |
|
19 | + { |
|
20 | + return strtoupper($value_to_normalize); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * It's kinda hard to unnormalize this- we can't determine which parts used to be lowercase |
|
27 | - * so just return it as-is. |
|
28 | - * |
|
29 | - * @param string $normalized_value |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function unnormalize($normalized_value) |
|
33 | - { |
|
34 | - return $normalized_value; |
|
35 | - } |
|
25 | + /** |
|
26 | + * It's kinda hard to unnormalize this- we can't determine which parts used to be lowercase |
|
27 | + * so just return it as-is. |
|
28 | + * |
|
29 | + * @param string $normalized_value |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function unnormalize($normalized_value) |
|
33 | + { |
|
34 | + return $normalized_value; |
|
35 | + } |
|
36 | 36 | } |
@@ -10,25 +10,25 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Slug_Normalization extends EE_Normalization_Strategy_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $value_to_normalize |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - public function normalize($value_to_normalize) |
|
18 | - { |
|
19 | - return sanitize_title($value_to_normalize); |
|
20 | - } |
|
13 | + /** |
|
14 | + * @param string $value_to_normalize |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + public function normalize($value_to_normalize) |
|
18 | + { |
|
19 | + return sanitize_title($value_to_normalize); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * It's hard to unnormalize this- let's just take a guess |
|
26 | - * |
|
27 | - * @param string $normalized_value |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function unnormalize($normalized_value) |
|
31 | - { |
|
32 | - return str_replace("-", " ", $normalized_value); |
|
33 | - } |
|
24 | + /** |
|
25 | + * It's hard to unnormalize this- let's just take a guess |
|
26 | + * |
|
27 | + * @param string $normalized_value |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function unnormalize($normalized_value) |
|
31 | + { |
|
32 | + return str_replace("-", " ", $normalized_value); |
|
33 | + } |
|
34 | 34 | } |
@@ -10,97 +10,97 @@ |
||
10 | 10 | */ |
11 | 11 | abstract class EE_Validation_Strategy_Base extends EE_Form_Input_Strategy_Base |
12 | 12 | { |
13 | - protected $_validation_error_message = ''; |
|
14 | - |
|
15 | - |
|
16 | - |
|
17 | - /** |
|
18 | - * @param null $validation_error_message |
|
19 | - */ |
|
20 | - public function __construct($validation_error_message = null) |
|
21 | - { |
|
22 | - $this->_validation_error_message = $validation_error_message === null |
|
23 | - ? esc_html__('Input invalid', 'event_espresso') |
|
24 | - : $validation_error_message; |
|
25 | - parent::__construct(); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * Performs validation on the request data that corresponds to this field. |
|
32 | - * If validation fails, should throw an EE_Validation_Error. |
|
33 | - * Note: most validate() functions should allow $normalized_value to be empty, |
|
34 | - * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty. |
|
35 | - * |
|
36 | - * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless |
|
37 | - * this validation strategy is the 'required' validation strategy, |
|
38 | - * most should be OK with a null, empty string, etc) |
|
39 | - */ |
|
40 | - public function validate($normalized_value) |
|
41 | - { |
|
42 | - // by default, the validation strategy does no validation. this should be implemented |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying. |
|
49 | - * For documentation, see http://jqueryvalidation.org/ |
|
50 | - * Eg to generate the following js for validation, <br><code> |
|
51 | - * $( "#myform" ).validate({ |
|
52 | - * rules: { |
|
53 | - * field_name: { |
|
54 | - * required: true, |
|
55 | - * minlength: 3, |
|
56 | - * equalTo: "#password" |
|
57 | - * } |
|
58 | - * } |
|
59 | - * }); |
|
60 | - * </code> |
|
61 | - * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ). |
|
62 | - * This is done so that if we are applying multiple sanitization strategies to a field, |
|
63 | - * we can easily combine them. |
|
64 | - * |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public function get_jquery_validation_rule_array() |
|
68 | - { |
|
69 | - return array(); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Gets the i18n validation error message for when this validation strategy finds |
|
76 | - * the input is invalid. Used for both frontend and backend validation. |
|
77 | - * |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public function get_validation_error_message() |
|
81 | - { |
|
82 | - return $this->_validation_error_message; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Adds js variables for localization to the $other_js_data. These should be put |
|
89 | - * in each form's "other_data" javascript object. |
|
90 | - * |
|
91 | - * @param array $other_js_data |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - public function get_other_js_data($other_js_data = array()) |
|
95 | - { |
|
96 | - return $other_js_data; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
101 | - * This should be called during wp_enqueue_scripts |
|
102 | - */ |
|
103 | - public function enqueue_js() |
|
104 | - { |
|
105 | - } |
|
13 | + protected $_validation_error_message = ''; |
|
14 | + |
|
15 | + |
|
16 | + |
|
17 | + /** |
|
18 | + * @param null $validation_error_message |
|
19 | + */ |
|
20 | + public function __construct($validation_error_message = null) |
|
21 | + { |
|
22 | + $this->_validation_error_message = $validation_error_message === null |
|
23 | + ? esc_html__('Input invalid', 'event_espresso') |
|
24 | + : $validation_error_message; |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * Performs validation on the request data that corresponds to this field. |
|
32 | + * If validation fails, should throw an EE_Validation_Error. |
|
33 | + * Note: most validate() functions should allow $normalized_value to be empty, |
|
34 | + * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty. |
|
35 | + * |
|
36 | + * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless |
|
37 | + * this validation strategy is the 'required' validation strategy, |
|
38 | + * most should be OK with a null, empty string, etc) |
|
39 | + */ |
|
40 | + public function validate($normalized_value) |
|
41 | + { |
|
42 | + // by default, the validation strategy does no validation. this should be implemented |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying. |
|
49 | + * For documentation, see http://jqueryvalidation.org/ |
|
50 | + * Eg to generate the following js for validation, <br><code> |
|
51 | + * $( "#myform" ).validate({ |
|
52 | + * rules: { |
|
53 | + * field_name: { |
|
54 | + * required: true, |
|
55 | + * minlength: 3, |
|
56 | + * equalTo: "#password" |
|
57 | + * } |
|
58 | + * } |
|
59 | + * }); |
|
60 | + * </code> |
|
61 | + * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ). |
|
62 | + * This is done so that if we are applying multiple sanitization strategies to a field, |
|
63 | + * we can easily combine them. |
|
64 | + * |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public function get_jquery_validation_rule_array() |
|
68 | + { |
|
69 | + return array(); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Gets the i18n validation error message for when this validation strategy finds |
|
76 | + * the input is invalid. Used for both frontend and backend validation. |
|
77 | + * |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public function get_validation_error_message() |
|
81 | + { |
|
82 | + return $this->_validation_error_message; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Adds js variables for localization to the $other_js_data. These should be put |
|
89 | + * in each form's "other_data" javascript object. |
|
90 | + * |
|
91 | + * @param array $other_js_data |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + public function get_other_js_data($other_js_data = array()) |
|
95 | + { |
|
96 | + return $other_js_data; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
101 | + * This should be called during wp_enqueue_scripts |
|
102 | + */ |
|
103 | + public function enqueue_js() |
|
104 | + { |
|
105 | + } |
|
106 | 106 | } |
@@ -13,112 +13,112 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Template_Part |
15 | 15 | { |
16 | - /** |
|
17 | - * @type string $name |
|
18 | - */ |
|
19 | - protected $name; |
|
20 | - |
|
21 | - /** |
|
22 | - * @type string $label |
|
23 | - */ |
|
24 | - protected $label; |
|
25 | - |
|
26 | - /** |
|
27 | - * @type string $template |
|
28 | - */ |
|
29 | - protected $template; |
|
30 | - |
|
31 | - /** |
|
32 | - * @type int $priority |
|
33 | - */ |
|
34 | - protected $priority; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * class constructor |
|
39 | - * |
|
40 | - * @param string $name |
|
41 | - * @param string $label |
|
42 | - * @param string $template |
|
43 | - * @param int $priority |
|
44 | - */ |
|
45 | - public function __construct($name, $label, $template, $priority = 100) |
|
46 | - { |
|
47 | - $this->set_name($name); |
|
48 | - $this->set_label($label); |
|
49 | - $this->set_template($template); |
|
50 | - $this->set_priority($priority); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @return mixed |
|
56 | - */ |
|
57 | - public function name() |
|
58 | - { |
|
59 | - return $this->name; |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @param mixed $name |
|
65 | - */ |
|
66 | - public function set_name($name) |
|
67 | - { |
|
68 | - $this->name = $name; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function label() |
|
76 | - { |
|
77 | - return $this->label; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $label |
|
83 | - */ |
|
84 | - public function set_label($label) |
|
85 | - { |
|
86 | - $this->label = $label; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function template() |
|
94 | - { |
|
95 | - return $this->template; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @param string $template |
|
101 | - */ |
|
102 | - public function set_template($template) |
|
103 | - { |
|
104 | - $this->template = $template; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return int |
|
110 | - */ |
|
111 | - public function priority() |
|
112 | - { |
|
113 | - return $this->priority; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @param int $priority |
|
119 | - */ |
|
120 | - public function set_priority($priority) |
|
121 | - { |
|
122 | - $this->priority = intval($priority); |
|
123 | - } |
|
16 | + /** |
|
17 | + * @type string $name |
|
18 | + */ |
|
19 | + protected $name; |
|
20 | + |
|
21 | + /** |
|
22 | + * @type string $label |
|
23 | + */ |
|
24 | + protected $label; |
|
25 | + |
|
26 | + /** |
|
27 | + * @type string $template |
|
28 | + */ |
|
29 | + protected $template; |
|
30 | + |
|
31 | + /** |
|
32 | + * @type int $priority |
|
33 | + */ |
|
34 | + protected $priority; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * class constructor |
|
39 | + * |
|
40 | + * @param string $name |
|
41 | + * @param string $label |
|
42 | + * @param string $template |
|
43 | + * @param int $priority |
|
44 | + */ |
|
45 | + public function __construct($name, $label, $template, $priority = 100) |
|
46 | + { |
|
47 | + $this->set_name($name); |
|
48 | + $this->set_label($label); |
|
49 | + $this->set_template($template); |
|
50 | + $this->set_priority($priority); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @return mixed |
|
56 | + */ |
|
57 | + public function name() |
|
58 | + { |
|
59 | + return $this->name; |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @param mixed $name |
|
65 | + */ |
|
66 | + public function set_name($name) |
|
67 | + { |
|
68 | + $this->name = $name; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function label() |
|
76 | + { |
|
77 | + return $this->label; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $label |
|
83 | + */ |
|
84 | + public function set_label($label) |
|
85 | + { |
|
86 | + $this->label = $label; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function template() |
|
94 | + { |
|
95 | + return $this->template; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @param string $template |
|
101 | + */ |
|
102 | + public function set_template($template) |
|
103 | + { |
|
104 | + $this->template = $template; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return int |
|
110 | + */ |
|
111 | + public function priority() |
|
112 | + { |
|
113 | + return $this->priority; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @param int $priority |
|
119 | + */ |
|
120 | + public function set_priority($priority) |
|
121 | + { |
|
122 | + $this->priority = intval($priority); |
|
123 | + } |
|
124 | 124 | } |
@@ -13,50 +13,50 @@ |
||
13 | 13 | */ |
14 | 14 | class EventListIframeEmbedButton extends IframeEmbedButton |
15 | 15 | { |
16 | - /** |
|
17 | - * EventListIframeEmbedButton constructor. |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct( |
|
22 | - esc_html__('Upcoming Event List', 'event_espresso'), |
|
23 | - 'event_list' |
|
24 | - ); |
|
25 | - } |
|
16 | + /** |
|
17 | + * EventListIframeEmbedButton constructor. |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct( |
|
22 | + esc_html__('Upcoming Event List', 'event_espresso'), |
|
23 | + 'event_list' |
|
24 | + ); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - public function addEmbedButton() |
|
29 | - { |
|
30 | - add_filter( |
|
31 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
|
32 | - array($this, 'addEventListIframeEmbedButtonSection'), |
|
33 | - 20 |
|
34 | - ); |
|
35 | - add_action( |
|
36 | - 'admin_enqueue_scripts', |
|
37 | - array($this, 'embedButtonAssets'), |
|
38 | - 10 |
|
39 | - ); |
|
40 | - } |
|
28 | + public function addEmbedButton() |
|
29 | + { |
|
30 | + add_filter( |
|
31 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
|
32 | + array($this, 'addEventListIframeEmbedButtonSection'), |
|
33 | + 20 |
|
34 | + ); |
|
35 | + add_action( |
|
36 | + 'admin_enqueue_scripts', |
|
37 | + array($this, 'embedButtonAssets'), |
|
38 | + 10 |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Adds an iframe embed code button to the Event editor. |
|
45 | - * return string |
|
46 | - * |
|
47 | - * @param array $after_list_table |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
51 | - { |
|
52 | - return EEH_Array::insert_into_array( |
|
53 | - $after_list_table, |
|
54 | - [ |
|
55 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
56 | - ['event_list' => $this->embedButtonHtml()] |
|
57 | - ), |
|
58 | - ], |
|
59 | - 'legend' |
|
60 | - ); |
|
61 | - } |
|
43 | + /** |
|
44 | + * Adds an iframe embed code button to the Event editor. |
|
45 | + * return string |
|
46 | + * |
|
47 | + * @param array $after_list_table |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
51 | + { |
|
52 | + return EEH_Array::insert_into_array( |
|
53 | + $after_list_table, |
|
54 | + [ |
|
55 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
56 | + ['event_list' => $this->embedButtonHtml()] |
|
57 | + ), |
|
58 | + ], |
|
59 | + 'legend' |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | } |
@@ -15,13 +15,13 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_Single_Registration_Line_Item_Filter extends EE_Specific_Registrations_Line_Item_Filter |
17 | 17 | { |
18 | - /** |
|
19 | - * |
|
20 | - * @param EE_Registration $registration |
|
21 | - * @throws EE_Error |
|
22 | - */ |
|
23 | - public function __construct($registration) |
|
24 | - { |
|
25 | - parent::__construct(array($registration)); |
|
26 | - } |
|
18 | + /** |
|
19 | + * |
|
20 | + * @param EE_Registration $registration |
|
21 | + * @throws EE_Error |
|
22 | + */ |
|
23 | + public function __construct($registration) |
|
24 | + { |
|
25 | + parent::__construct(array($registration)); |
|
26 | + } |
|
27 | 27 | } |
@@ -14,14 +14,14 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class EE_Line_Item_Filter_Base implements EE_Line_Item_Filter |
16 | 16 | { |
17 | - /** |
|
18 | - * process |
|
19 | - * |
|
20 | - * @param EE_Line_Item $line_item |
|
21 | - * @return EE_Line_Item |
|
22 | - */ |
|
23 | - public function process(EE_Line_Item $line_item): ?EE_Line_Item |
|
24 | - { |
|
25 | - return $line_item; |
|
26 | - } |
|
17 | + /** |
|
18 | + * process |
|
19 | + * |
|
20 | + * @param EE_Line_Item $line_item |
|
21 | + * @return EE_Line_Item |
|
22 | + */ |
|
23 | + public function process(EE_Line_Item $line_item): ?EE_Line_Item |
|
24 | + { |
|
25 | + return $line_item; |
|
26 | + } |
|
27 | 27 | } |
@@ -35,95 +35,95 @@ |
||
35 | 35 | */ |
36 | 36 | class EE_Line_Item_Filter_Processor |
37 | 37 | { |
38 | - /** |
|
39 | - * @type EE_Line_Item_Filter_Collection $line_item_filters |
|
40 | - */ |
|
41 | - protected $line_item_filters; |
|
38 | + /** |
|
39 | + * @type EE_Line_Item_Filter_Collection $line_item_filters |
|
40 | + */ |
|
41 | + protected $line_item_filters; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @type EE_Line_Item $grand_total_line_item |
|
45 | - */ |
|
46 | - protected $grand_total_line_item; |
|
43 | + /** |
|
44 | + * @type EE_Line_Item $grand_total_line_item |
|
45 | + */ |
|
46 | + protected $grand_total_line_item; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * EE_Line_Item_Filter_Processor constructor. |
|
51 | - * |
|
52 | - * @param EE_Line_Item_Filter_Collection $line_item_filters |
|
53 | - * @param EE_Line_Item $grand_total_line_item |
|
54 | - * @throws EE_Error |
|
55 | - * @throws ReflectionException |
|
56 | - */ |
|
57 | - public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EE_Line_Item $grand_total_line_item) |
|
58 | - { |
|
59 | - $this->line_item_filters = $line_item_filters; |
|
60 | - if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) { |
|
61 | - throw new EE_Error(esc_html__('A Line Item of the type total is required', 'event_espresso')); |
|
62 | - } |
|
63 | - $this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item); |
|
64 | - } |
|
49 | + /** |
|
50 | + * EE_Line_Item_Filter_Processor constructor. |
|
51 | + * |
|
52 | + * @param EE_Line_Item_Filter_Collection $line_item_filters |
|
53 | + * @param EE_Line_Item $grand_total_line_item |
|
54 | + * @throws EE_Error |
|
55 | + * @throws ReflectionException |
|
56 | + */ |
|
57 | + public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EE_Line_Item $grand_total_line_item) |
|
58 | + { |
|
59 | + $this->line_item_filters = $line_item_filters; |
|
60 | + if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) { |
|
61 | + throw new EE_Error(esc_html__('A Line Item of the type total is required', 'event_espresso')); |
|
62 | + } |
|
63 | + $this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * clone_and_reset_line_item_tree |
|
69 | - * |
|
70 | - * @param EE_Line_Item $line_item |
|
71 | - * @return EE_Line_Item |
|
72 | - * @throws EE_Error |
|
73 | - * @throws ReflectionException |
|
74 | - */ |
|
75 | - protected function clone_and_reset_line_item_tree(EE_Line_Item $line_item): EE_Line_Item |
|
76 | - { |
|
77 | - $cloned_line_item = $this->clone_and_reset_line_item($line_item); |
|
78 | - foreach ($line_item->children() as $child_line_item) { |
|
79 | - $cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item)); |
|
80 | - } |
|
81 | - return $cloned_line_item; |
|
82 | - } |
|
67 | + /** |
|
68 | + * clone_and_reset_line_item_tree |
|
69 | + * |
|
70 | + * @param EE_Line_Item $line_item |
|
71 | + * @return EE_Line_Item |
|
72 | + * @throws EE_Error |
|
73 | + * @throws ReflectionException |
|
74 | + */ |
|
75 | + protected function clone_and_reset_line_item_tree(EE_Line_Item $line_item): EE_Line_Item |
|
76 | + { |
|
77 | + $cloned_line_item = $this->clone_and_reset_line_item($line_item); |
|
78 | + foreach ($line_item->children() as $child_line_item) { |
|
79 | + $cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item)); |
|
80 | + } |
|
81 | + return $cloned_line_item; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * clone_and_reset_line_item |
|
87 | - * |
|
88 | - * clones the incoming object |
|
89 | - * resets any fields that represent database primary keys |
|
90 | - * resets total |
|
91 | - * |
|
92 | - * @param EE_Line_Item $line_item |
|
93 | - * @return EE_Line_Item |
|
94 | - * @throws EE_Error |
|
95 | - * @throws ReflectionException |
|
96 | - */ |
|
97 | - protected function clone_and_reset_line_item(EE_Line_Item $line_item): EE_Line_Item |
|
98 | - { |
|
99 | - // we don't actually want to work with the original line item, so clone it |
|
100 | - $cloned_line_item = clone $line_item; |
|
101 | - $cloned_line_item->set('LIN_ID', null); |
|
102 | - $cloned_line_item->set('LIN_parent', null); |
|
103 | - $cloned_line_item->clear_related_line_item_cache(); |
|
104 | - foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) { |
|
105 | - $cloned_line_item->clear_cache($relation_name, null, true); |
|
106 | - } |
|
107 | - $cloned_line_item->set_allow_persist(false); |
|
108 | - return $cloned_line_item; |
|
109 | - } |
|
85 | + /** |
|
86 | + * clone_and_reset_line_item |
|
87 | + * |
|
88 | + * clones the incoming object |
|
89 | + * resets any fields that represent database primary keys |
|
90 | + * resets total |
|
91 | + * |
|
92 | + * @param EE_Line_Item $line_item |
|
93 | + * @return EE_Line_Item |
|
94 | + * @throws EE_Error |
|
95 | + * @throws ReflectionException |
|
96 | + */ |
|
97 | + protected function clone_and_reset_line_item(EE_Line_Item $line_item): EE_Line_Item |
|
98 | + { |
|
99 | + // we don't actually want to work with the original line item, so clone it |
|
100 | + $cloned_line_item = clone $line_item; |
|
101 | + $cloned_line_item->set('LIN_ID', null); |
|
102 | + $cloned_line_item->set('LIN_parent', null); |
|
103 | + $cloned_line_item->clear_related_line_item_cache(); |
|
104 | + foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) { |
|
105 | + $cloned_line_item->clear_cache($relation_name, null, true); |
|
106 | + } |
|
107 | + $cloned_line_item->set_allow_persist(false); |
|
108 | + return $cloned_line_item; |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * process |
|
114 | - * |
|
115 | - * @return EE_Line_Item |
|
116 | - * @throws EE_Error |
|
117 | - * @throws ReflectionException |
|
118 | - */ |
|
119 | - public function process(): ?EE_Line_Item |
|
120 | - { |
|
121 | - $this->line_item_filters->rewind(); |
|
122 | - while ($this->line_item_filters->valid()) { |
|
123 | - $this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item); |
|
124 | - $this->line_item_filters->next(); |
|
125 | - } |
|
126 | - $this->grand_total_line_item->recalculate_total_including_taxes(); |
|
127 | - return $this->grand_total_line_item; |
|
128 | - } |
|
112 | + /** |
|
113 | + * process |
|
114 | + * |
|
115 | + * @return EE_Line_Item |
|
116 | + * @throws EE_Error |
|
117 | + * @throws ReflectionException |
|
118 | + */ |
|
119 | + public function process(): ?EE_Line_Item |
|
120 | + { |
|
121 | + $this->line_item_filters->rewind(); |
|
122 | + while ($this->line_item_filters->valid()) { |
|
123 | + $this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item); |
|
124 | + $this->line_item_filters->next(); |
|
125 | + } |
|
126 | + $this->grand_total_line_item->recalculate_total_including_taxes(); |
|
127 | + return $this->grand_total_line_item; |
|
128 | + } |
|
129 | 129 | } |