@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Unique_Index extends EE_Index |
8 | 8 | { |
9 | - // yep, actually the same as index right now |
|
9 | + // yep, actually the same as index right now |
|
10 | 10 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Primary_Key_Index extends EE_Unique_Index |
8 | 8 | { |
9 | - // yep, actually the same as unique index right now |
|
9 | + // yep, actually the same as unique index right now |
|
10 | 10 | } |
@@ -14,141 +14,141 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
16 | 16 | */ |
17 | - private $_join_sql; |
|
17 | + private $_join_sql; |
|
18 | 18 | /** |
19 | 19 | * |
20 | 20 | * @var array stating all the models that have been included thus far,so we don't get duplicates. |
21 | 21 | * Keys are the model relation chains to them from the queried model |
22 | 22 | * (eg, "Registration.Transaction.Payment"), and valuesare model names (eg "Payment") |
23 | 23 | */ |
24 | - private $_models_included; |
|
24 | + private $_models_included; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * After we've acquired all the data types, we can create this sql. |
28 | 28 | * @var string |
29 | 29 | */ |
30 | - private $_where_sql; |
|
30 | + private $_where_sql; |
|
31 | 31 | /** |
32 | 32 | * Full join sql. Eg, in a select query, that's everything after the "FROM", and before the "WHERE", so it includes |
33 | 33 | * the declaration of the main model's tables, and then appends all the joining sql to other models |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - private $_main_join_sql; |
|
36 | + private $_main_join_sql; |
|
37 | 37 | |
38 | 38 | |
39 | - private $_limit_sql; |
|
39 | + private $_limit_sql; |
|
40 | 40 | |
41 | - private $_order_by_sql; |
|
41 | + private $_order_by_sql; |
|
42 | 42 | |
43 | - private $_having_sql; |
|
43 | + private $_having_sql; |
|
44 | 44 | |
45 | - private $_group_by_sql; |
|
45 | + private $_group_by_sql; |
|
46 | 46 | |
47 | - public function set_limit_sql($limit_sql) |
|
48 | - { |
|
49 | - $this->_limit_sql = $limit_sql; |
|
50 | - } |
|
47 | + public function set_limit_sql($limit_sql) |
|
48 | + { |
|
49 | + $this->_limit_sql = $limit_sql; |
|
50 | + } |
|
51 | 51 | |
52 | - public function set_order_by_sql($order_by_sql) |
|
53 | - { |
|
54 | - $this->_order_by_sql = $order_by_sql; |
|
55 | - } |
|
56 | - public function set_group_by_sql($group_by_sql) |
|
57 | - { |
|
58 | - $this->_group_by_sql = $group_by_sql; |
|
59 | - } |
|
60 | - public function set_having_sql($having_sql) |
|
61 | - { |
|
62 | - $this->_having_sql = $having_sql; |
|
63 | - } |
|
64 | - public function get_limit_sql() |
|
65 | - { |
|
66 | - return $this->_limit_sql; |
|
67 | - } |
|
68 | - public function get_order_by_sql() |
|
69 | - { |
|
70 | - return $this->_order_by_sql; |
|
71 | - } |
|
72 | - public function get_group_by_sql() |
|
73 | - { |
|
74 | - return $this->_group_by_sql; |
|
75 | - } |
|
76 | - public function get_having_sql() |
|
77 | - { |
|
78 | - return $this->_having_sql; |
|
79 | - } |
|
52 | + public function set_order_by_sql($order_by_sql) |
|
53 | + { |
|
54 | + $this->_order_by_sql = $order_by_sql; |
|
55 | + } |
|
56 | + public function set_group_by_sql($group_by_sql) |
|
57 | + { |
|
58 | + $this->_group_by_sql = $group_by_sql; |
|
59 | + } |
|
60 | + public function set_having_sql($having_sql) |
|
61 | + { |
|
62 | + $this->_having_sql = $having_sql; |
|
63 | + } |
|
64 | + public function get_limit_sql() |
|
65 | + { |
|
66 | + return $this->_limit_sql; |
|
67 | + } |
|
68 | + public function get_order_by_sql() |
|
69 | + { |
|
70 | + return $this->_order_by_sql; |
|
71 | + } |
|
72 | + public function get_group_by_sql() |
|
73 | + { |
|
74 | + return $this->_group_by_sql; |
|
75 | + } |
|
76 | + public function get_having_sql() |
|
77 | + { |
|
78 | + return $this->_having_sql; |
|
79 | + } |
|
80 | 80 | /** |
81 | 81 | * |
82 | 82 | * @param type $model_included_name |
83 | 83 | * @param type $join_sql |
84 | 84 | * @param type $data_types |
85 | 85 | */ |
86 | - public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | - { |
|
88 | - $this->_models_included = $model_included_name; |
|
89 | - $this->_join_sql = $join_sql; |
|
90 | - } |
|
86 | + public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | + { |
|
88 | + $this->_models_included = $model_included_name; |
|
89 | + $this->_join_sql = $join_sql; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Merges info from the other EEM_Related_Model_Info_Carrier into this one. |
94 | 94 | * @param EE_Model_Query_Info_Carrier $other_model_query_info_carrier |
95 | 95 | */ |
96 | - public function merge($other_model_query_info_carrier) |
|
97 | - { |
|
98 | - if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | - $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | - $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | - } |
|
103 | - // otherwise don't merge our data. |
|
104 | - // yes, this means that we must immediately merge any model data into our grand list |
|
105 | - // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | - // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | - } |
|
96 | + public function merge($other_model_query_info_carrier) |
|
97 | + { |
|
98 | + if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | + $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | + $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | + } |
|
103 | + // otherwise don't merge our data. |
|
104 | + // yes, this means that we must immediately merge any model data into our grand list |
|
105 | + // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | + // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | + } |
|
108 | 108 | /** |
109 | 109 | * Checks whether or not we have already included all the models mentione din $model_names on the query info varrier |
110 | 110 | * @param array $model_names just like EE_MOdel_QUery_Info_Carrier::_models_included: keys are model chain paths, values are the model names only |
111 | 111 | * @return boolean |
112 | 112 | */ |
113 | - protected function _have_already_included_one_of_these_models($model_names) |
|
114 | - { |
|
115 | - foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | - if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | - return true; |
|
118 | - } |
|
119 | - } |
|
120 | - return false; |
|
121 | - } |
|
113 | + protected function _have_already_included_one_of_these_models($model_names) |
|
114 | + { |
|
115 | + foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | + if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | + return true; |
|
118 | + } |
|
119 | + } |
|
120 | + return false; |
|
121 | + } |
|
122 | 122 | /** |
123 | 123 | * Array keys are model names, values are "model relation paths". See EE_Model_Query_Info_Carrier::_models_included for details |
124 | 124 | * @return array like EE_Model_Query_Info_Carrier::_models_included |
125 | 125 | */ |
126 | - public function get_model_names_included() |
|
127 | - { |
|
128 | - return $this->_models_included; |
|
129 | - } |
|
126 | + public function get_model_names_included() |
|
127 | + { |
|
128 | + return $this->_models_included; |
|
129 | + } |
|
130 | 130 | /** |
131 | 131 | * sets the $where_sql for later use from client code |
132 | 132 | * @param string $where_sql |
133 | 133 | */ |
134 | - public function set_where_sql($where_sql) |
|
135 | - { |
|
136 | - $this->_where_sql = $where_sql; |
|
137 | - } |
|
138 | - public function get_where_sql() |
|
139 | - { |
|
140 | - return $this->_where_sql; |
|
141 | - } |
|
134 | + public function set_where_sql($where_sql) |
|
135 | + { |
|
136 | + $this->_where_sql = $where_sql; |
|
137 | + } |
|
138 | + public function get_where_sql() |
|
139 | + { |
|
140 | + return $this->_where_sql; |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Gets the SQL for joining the main model to other models involves in the query, which was set earlier on |
145 | 145 | * the EE_Model_Query_info_Carrier by calling set_main_model_join_sql() |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function get_main_model_join_sql() |
|
149 | - { |
|
150 | - return $this->_main_join_sql; |
|
151 | - } |
|
148 | + public function get_main_model_join_sql() |
|
149 | + { |
|
150 | + return $this->_main_join_sql; |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | 154 | /** |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * after the FROM and before the WHERE.) |
159 | 159 | * @param string $join_sql |
160 | 160 | */ |
161 | - public function set_main_model_join_sql($join_sql) |
|
162 | - { |
|
163 | - $this->_main_join_sql = $join_sql; |
|
164 | - } |
|
165 | - public function get_full_join_sql() |
|
166 | - { |
|
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
168 | - } |
|
161 | + public function set_main_model_join_sql($join_sql) |
|
162 | + { |
|
163 | + $this->_main_join_sql = $join_sql; |
|
164 | + } |
|
165 | + public function get_full_join_sql() |
|
166 | + { |
|
167 | + return $this->_main_join_sql . $this->_join_sql; |
|
168 | + } |
|
169 | 169 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function merge($other_model_query_info_carrier) |
97 | 97 | { |
98 | 98 | if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | 100 | $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
101 | 101 | $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
102 | 102 | } |
@@ -164,6 +164,6 @@ discard block |
||
164 | 164 | } |
165 | 165 | public function get_full_join_sql() |
166 | 166 | { |
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
167 | + return $this->_main_join_sql.$this->_join_sql; |
|
168 | 168 | } |
169 | 169 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | self::$_instance = new self($grand_total, $session); |
66 | 66 | } |
67 | 67 | // or maybe retrieve an existing one ? |
68 | - if (! self::$_instance instanceof EE_Cart) { |
|
68 | + if ( ! self::$_instance instanceof EE_Cart) { |
|
69 | 69 | // try getting the cart out of the session |
70 | 70 | $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
71 | 71 | self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
72 | 72 | unset($saved_cart); |
73 | 73 | } |
74 | 74 | // verify that cart is ok and grand total line item exists |
75 | - if (! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
75 | + if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
76 | 76 | self::$_instance = new self($grand_total, $session); |
77 | 77 | } |
78 | 78 | self::$_instance->get_grand_total(); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function session() |
126 | 126 | { |
127 | - if (! $this->_session instanceof EE_Session) { |
|
127 | + if ( ! $this->_session instanceof EE_Session) { |
|
128 | 128 | $this->set_session(); |
129 | 129 | } |
130 | 130 | return $this->_session; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | public function __wakeup() |
394 | 394 | { |
395 | - if (! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
395 | + if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
396 | 396 | // $this->_grand_total is actually just an ID, so use it to get the object from the db |
397 | 397 | $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
398 | 398 | } |
@@ -17,397 +17,397 @@ |
||
17 | 17 | class EE_Cart implements ResettableInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * instance of the EE_Cart object |
|
22 | - * |
|
23 | - * @access private |
|
24 | - * @var EE_Cart $_instance |
|
25 | - */ |
|
26 | - private static $_instance; |
|
27 | - |
|
28 | - /** |
|
29 | - * instance of the EE_Session object |
|
30 | - * |
|
31 | - * @access protected |
|
32 | - * @var EE_Session $_session |
|
33 | - */ |
|
34 | - protected $_session; |
|
35 | - |
|
36 | - /** |
|
37 | - * The total Line item which comprises all the children line-item subtotals, |
|
38 | - * which in turn each have their line items. |
|
39 | - * Typically, the line item structure will look like: |
|
40 | - * grand total |
|
41 | - * -tickets-sub-total |
|
42 | - * --ticket1 |
|
43 | - * --ticket2 |
|
44 | - * --... |
|
45 | - * -taxes-sub-total |
|
46 | - * --tax1 |
|
47 | - * --tax2 |
|
48 | - * |
|
49 | - * @var EE_Line_Item |
|
50 | - */ |
|
51 | - private $_grand_total; |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @singleton method used to instantiate class object |
|
56 | - * @access public |
|
57 | - * @param EE_Line_Item $grand_total |
|
58 | - * @param EE_Session $session |
|
59 | - * @return \EE_Cart |
|
60 | - * @throws \EE_Error |
|
61 | - */ |
|
62 | - public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
63 | - { |
|
64 | - if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
65 | - self::$_instance = new self($grand_total, $session); |
|
66 | - } |
|
67 | - // or maybe retrieve an existing one ? |
|
68 | - if (! self::$_instance instanceof EE_Cart) { |
|
69 | - // try getting the cart out of the session |
|
70 | - $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
|
71 | - self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
|
72 | - unset($saved_cart); |
|
73 | - } |
|
74 | - // verify that cart is ok and grand total line item exists |
|
75 | - if (! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
76 | - self::$_instance = new self($grand_total, $session); |
|
77 | - } |
|
78 | - self::$_instance->get_grand_total(); |
|
79 | - // once everything is all said and done, save the cart to the EE_Session |
|
80 | - add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
81 | - return self::$_instance; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * private constructor to prevent direct creation |
|
87 | - * |
|
88 | - * @Constructor |
|
89 | - * @access private |
|
90 | - * @param EE_Line_Item $grand_total |
|
91 | - * @param EE_Session $session |
|
92 | - */ |
|
93 | - private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
94 | - { |
|
95 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
96 | - $this->set_session($session); |
|
97 | - if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
98 | - $this->set_grand_total_line_item($grand_total); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Resets the cart completely (whereas empty_cart |
|
105 | - * |
|
106 | - * @param EE_Line_Item $grand_total |
|
107 | - * @param EE_Session $session |
|
108 | - * @return EE_Cart |
|
109 | - * @throws \EE_Error |
|
110 | - */ |
|
111 | - public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
112 | - { |
|
113 | - remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
114 | - if ($session instanceof EE_Session) { |
|
115 | - $session->reset_cart(); |
|
116 | - } |
|
117 | - self::$_instance = null; |
|
118 | - return self::instance($grand_total, $session); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return \EE_Session |
|
124 | - */ |
|
125 | - public function session() |
|
126 | - { |
|
127 | - if (! $this->_session instanceof EE_Session) { |
|
128 | - $this->set_session(); |
|
129 | - } |
|
130 | - return $this->_session; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param EE_Session $session |
|
136 | - */ |
|
137 | - public function set_session(EE_Session $session = null) |
|
138 | - { |
|
139 | - $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session'); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * Sets the cart to match the line item. Especially handy for loading an old cart where you |
|
145 | - * know the grand total line item on it |
|
146 | - * |
|
147 | - * @param EE_Line_Item $line_item |
|
148 | - */ |
|
149 | - public function set_grand_total_line_item(EE_Line_Item $line_item) |
|
150 | - { |
|
151 | - $this->_grand_total = $line_item; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * get_cart_from_reg_url_link |
|
157 | - * |
|
158 | - * @access public |
|
159 | - * @param EE_Transaction $transaction |
|
160 | - * @param EE_Session $session |
|
161 | - * @return \EE_Cart |
|
162 | - * @throws \EE_Error |
|
163 | - */ |
|
164 | - public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null) |
|
165 | - { |
|
166 | - $grand_total = $transaction->total_line_item(); |
|
167 | - $grand_total->get_items(); |
|
168 | - $grand_total->tax_descendants(); |
|
169 | - return EE_Cart::instance($grand_total, $session); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
|
175 | - * |
|
176 | - * @return EE_Line_Item |
|
177 | - * @throws \EE_Error |
|
178 | - */ |
|
179 | - private function _create_grand_total() |
|
180 | - { |
|
181 | - $this->_grand_total = EEH_Line_Item::create_total_line_item(); |
|
182 | - return $this->_grand_total; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Gets all the line items of object type Ticket |
|
188 | - * |
|
189 | - * @access public |
|
190 | - * @return \EE_Line_Item[] |
|
191 | - */ |
|
192 | - public function get_tickets() |
|
193 | - { |
|
194 | - if ($this->_grand_total === null) { |
|
195 | - return array(); |
|
196 | - } |
|
197 | - return EEH_Line_Item::get_ticket_line_items($this->_grand_total); |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * returns the total quantity of tickets in the cart |
|
203 | - * |
|
204 | - * @access public |
|
205 | - * @return int |
|
206 | - * @throws \EE_Error |
|
207 | - */ |
|
208 | - public function all_ticket_quantity_count() |
|
209 | - { |
|
210 | - $tickets = $this->get_tickets(); |
|
211 | - if (empty($tickets)) { |
|
212 | - return 0; |
|
213 | - } |
|
214 | - $count = 0; |
|
215 | - foreach ($tickets as $ticket) { |
|
216 | - $count += $ticket->get('LIN_quantity'); |
|
217 | - } |
|
218 | - return $count; |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * Gets all the tax line items |
|
224 | - * |
|
225 | - * @return \EE_Line_Item[] |
|
226 | - * @throws \EE_Error |
|
227 | - */ |
|
228 | - public function get_taxes() |
|
229 | - { |
|
230 | - return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * Gets the total line item (which is a parent of all other line items) on this cart |
|
236 | - * |
|
237 | - * @return EE_Line_Item |
|
238 | - * @throws \EE_Error |
|
239 | - */ |
|
240 | - public function get_grand_total() |
|
241 | - { |
|
242 | - return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @process items for adding to cart |
|
248 | - * @access public |
|
249 | - * @param EE_Ticket $ticket |
|
250 | - * @param int $qty |
|
251 | - * @return TRUE on success, FALSE on fail |
|
252 | - * @throws \EE_Error |
|
253 | - */ |
|
254 | - public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) |
|
255 | - { |
|
256 | - EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty); |
|
257 | - return $this->save_cart() ? true : false; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * get_cart_total_before_tax |
|
263 | - * |
|
264 | - * @access public |
|
265 | - * @return float |
|
266 | - * @throws \EE_Error |
|
267 | - */ |
|
268 | - public function get_cart_total_before_tax() |
|
269 | - { |
|
270 | - return $this->get_grand_total()->recalculate_pre_tax_total(); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * gets the total amount of tax paid for items in this cart |
|
276 | - * |
|
277 | - * @access public |
|
278 | - * @return float |
|
279 | - * @throws \EE_Error |
|
280 | - */ |
|
281 | - public function get_applied_taxes() |
|
282 | - { |
|
283 | - return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
289 | - * |
|
290 | - * @access public |
|
291 | - * @return float |
|
292 | - * @throws \EE_Error |
|
293 | - */ |
|
294 | - public function get_cart_grand_total() |
|
295 | - { |
|
296 | - EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
297 | - return $this->get_grand_total()->total(); |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
303 | - * |
|
304 | - * @access public |
|
305 | - * @return float |
|
306 | - * @throws \EE_Error |
|
307 | - */ |
|
308 | - public function recalculate_all_cart_totals() |
|
309 | - { |
|
310 | - $pre_tax_total = $this->get_cart_total_before_tax(); |
|
311 | - $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
312 | - $this->_grand_total->set_total($pre_tax_total + $taxes_total); |
|
313 | - $this->_grand_total->save_this_and_descendants_to_txn(); |
|
314 | - return $this->get_grand_total()->total(); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * deletes an item from the cart |
|
320 | - * |
|
321 | - * @access public |
|
322 | - * @param array|bool|string $line_item_codes |
|
323 | - * @return int on success, FALSE on fail |
|
324 | - * @throws \EE_Error |
|
325 | - */ |
|
326 | - public function delete_items($line_item_codes = false) |
|
327 | - { |
|
328 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
329 | - return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - /** |
|
334 | - * @remove ALL items from cart and zero ALL totals |
|
335 | - * @access public |
|
336 | - * @return bool |
|
337 | - * @throws \EE_Error |
|
338 | - */ |
|
339 | - public function empty_cart() |
|
340 | - { |
|
341 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
342 | - $this->_grand_total = $this->_create_grand_total(); |
|
343 | - return $this->save_cart(true); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @remove ALL items from cart and delete total as well |
|
349 | - * @access public |
|
350 | - * @return bool |
|
351 | - * @throws \EE_Error |
|
352 | - */ |
|
353 | - public function delete_cart() |
|
354 | - { |
|
355 | - if ($this->_grand_total instanceof EE_Line_Item) { |
|
356 | - $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total); |
|
357 | - if ($deleted) { |
|
358 | - $deleted += $this->_grand_total->delete(); |
|
359 | - $this->_grand_total = null; |
|
360 | - return true; |
|
361 | - } |
|
362 | - } |
|
363 | - return false; |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @save cart to session |
|
369 | - * @access public |
|
370 | - * @param bool $apply_taxes |
|
371 | - * @return TRUE on success, FALSE on fail |
|
372 | - * @throws \EE_Error |
|
373 | - */ |
|
374 | - public function save_cart($apply_taxes = true) |
|
375 | - { |
|
376 | - if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) { |
|
377 | - EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
378 | - // make sure we don't cache the transaction because it can get stale |
|
379 | - if ( |
|
380 | - $this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction |
|
381 | - && $this->_grand_total->get_one_from_cache('Transaction')->ID() |
|
382 | - ) { |
|
383 | - $this->_grand_total->clear_cache('Transaction', null, true); |
|
384 | - } |
|
385 | - } |
|
386 | - if ($this->session() instanceof EE_Session) { |
|
387 | - return $this->session()->set_cart($this); |
|
388 | - } else { |
|
389 | - return false; |
|
390 | - } |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - public function __wakeup() |
|
395 | - { |
|
396 | - if (! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
397 | - // $this->_grand_total is actually just an ID, so use it to get the object from the db |
|
398 | - $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * @return array |
|
405 | - */ |
|
406 | - public function __sleep() |
|
407 | - { |
|
408 | - if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) { |
|
409 | - $this->_grand_total = $this->_grand_total->ID(); |
|
410 | - } |
|
411 | - return array('_grand_total'); |
|
412 | - } |
|
20 | + /** |
|
21 | + * instance of the EE_Cart object |
|
22 | + * |
|
23 | + * @access private |
|
24 | + * @var EE_Cart $_instance |
|
25 | + */ |
|
26 | + private static $_instance; |
|
27 | + |
|
28 | + /** |
|
29 | + * instance of the EE_Session object |
|
30 | + * |
|
31 | + * @access protected |
|
32 | + * @var EE_Session $_session |
|
33 | + */ |
|
34 | + protected $_session; |
|
35 | + |
|
36 | + /** |
|
37 | + * The total Line item which comprises all the children line-item subtotals, |
|
38 | + * which in turn each have their line items. |
|
39 | + * Typically, the line item structure will look like: |
|
40 | + * grand total |
|
41 | + * -tickets-sub-total |
|
42 | + * --ticket1 |
|
43 | + * --ticket2 |
|
44 | + * --... |
|
45 | + * -taxes-sub-total |
|
46 | + * --tax1 |
|
47 | + * --tax2 |
|
48 | + * |
|
49 | + * @var EE_Line_Item |
|
50 | + */ |
|
51 | + private $_grand_total; |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @singleton method used to instantiate class object |
|
56 | + * @access public |
|
57 | + * @param EE_Line_Item $grand_total |
|
58 | + * @param EE_Session $session |
|
59 | + * @return \EE_Cart |
|
60 | + * @throws \EE_Error |
|
61 | + */ |
|
62 | + public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
63 | + { |
|
64 | + if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
65 | + self::$_instance = new self($grand_total, $session); |
|
66 | + } |
|
67 | + // or maybe retrieve an existing one ? |
|
68 | + if (! self::$_instance instanceof EE_Cart) { |
|
69 | + // try getting the cart out of the session |
|
70 | + $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
|
71 | + self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
|
72 | + unset($saved_cart); |
|
73 | + } |
|
74 | + // verify that cart is ok and grand total line item exists |
|
75 | + if (! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
76 | + self::$_instance = new self($grand_total, $session); |
|
77 | + } |
|
78 | + self::$_instance->get_grand_total(); |
|
79 | + // once everything is all said and done, save the cart to the EE_Session |
|
80 | + add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
81 | + return self::$_instance; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * private constructor to prevent direct creation |
|
87 | + * |
|
88 | + * @Constructor |
|
89 | + * @access private |
|
90 | + * @param EE_Line_Item $grand_total |
|
91 | + * @param EE_Session $session |
|
92 | + */ |
|
93 | + private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
94 | + { |
|
95 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
96 | + $this->set_session($session); |
|
97 | + if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
98 | + $this->set_grand_total_line_item($grand_total); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Resets the cart completely (whereas empty_cart |
|
105 | + * |
|
106 | + * @param EE_Line_Item $grand_total |
|
107 | + * @param EE_Session $session |
|
108 | + * @return EE_Cart |
|
109 | + * @throws \EE_Error |
|
110 | + */ |
|
111 | + public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
112 | + { |
|
113 | + remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
114 | + if ($session instanceof EE_Session) { |
|
115 | + $session->reset_cart(); |
|
116 | + } |
|
117 | + self::$_instance = null; |
|
118 | + return self::instance($grand_total, $session); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return \EE_Session |
|
124 | + */ |
|
125 | + public function session() |
|
126 | + { |
|
127 | + if (! $this->_session instanceof EE_Session) { |
|
128 | + $this->set_session(); |
|
129 | + } |
|
130 | + return $this->_session; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param EE_Session $session |
|
136 | + */ |
|
137 | + public function set_session(EE_Session $session = null) |
|
138 | + { |
|
139 | + $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session'); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * Sets the cart to match the line item. Especially handy for loading an old cart where you |
|
145 | + * know the grand total line item on it |
|
146 | + * |
|
147 | + * @param EE_Line_Item $line_item |
|
148 | + */ |
|
149 | + public function set_grand_total_line_item(EE_Line_Item $line_item) |
|
150 | + { |
|
151 | + $this->_grand_total = $line_item; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * get_cart_from_reg_url_link |
|
157 | + * |
|
158 | + * @access public |
|
159 | + * @param EE_Transaction $transaction |
|
160 | + * @param EE_Session $session |
|
161 | + * @return \EE_Cart |
|
162 | + * @throws \EE_Error |
|
163 | + */ |
|
164 | + public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null) |
|
165 | + { |
|
166 | + $grand_total = $transaction->total_line_item(); |
|
167 | + $grand_total->get_items(); |
|
168 | + $grand_total->tax_descendants(); |
|
169 | + return EE_Cart::instance($grand_total, $session); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
|
175 | + * |
|
176 | + * @return EE_Line_Item |
|
177 | + * @throws \EE_Error |
|
178 | + */ |
|
179 | + private function _create_grand_total() |
|
180 | + { |
|
181 | + $this->_grand_total = EEH_Line_Item::create_total_line_item(); |
|
182 | + return $this->_grand_total; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Gets all the line items of object type Ticket |
|
188 | + * |
|
189 | + * @access public |
|
190 | + * @return \EE_Line_Item[] |
|
191 | + */ |
|
192 | + public function get_tickets() |
|
193 | + { |
|
194 | + if ($this->_grand_total === null) { |
|
195 | + return array(); |
|
196 | + } |
|
197 | + return EEH_Line_Item::get_ticket_line_items($this->_grand_total); |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * returns the total quantity of tickets in the cart |
|
203 | + * |
|
204 | + * @access public |
|
205 | + * @return int |
|
206 | + * @throws \EE_Error |
|
207 | + */ |
|
208 | + public function all_ticket_quantity_count() |
|
209 | + { |
|
210 | + $tickets = $this->get_tickets(); |
|
211 | + if (empty($tickets)) { |
|
212 | + return 0; |
|
213 | + } |
|
214 | + $count = 0; |
|
215 | + foreach ($tickets as $ticket) { |
|
216 | + $count += $ticket->get('LIN_quantity'); |
|
217 | + } |
|
218 | + return $count; |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * Gets all the tax line items |
|
224 | + * |
|
225 | + * @return \EE_Line_Item[] |
|
226 | + * @throws \EE_Error |
|
227 | + */ |
|
228 | + public function get_taxes() |
|
229 | + { |
|
230 | + return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * Gets the total line item (which is a parent of all other line items) on this cart |
|
236 | + * |
|
237 | + * @return EE_Line_Item |
|
238 | + * @throws \EE_Error |
|
239 | + */ |
|
240 | + public function get_grand_total() |
|
241 | + { |
|
242 | + return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @process items for adding to cart |
|
248 | + * @access public |
|
249 | + * @param EE_Ticket $ticket |
|
250 | + * @param int $qty |
|
251 | + * @return TRUE on success, FALSE on fail |
|
252 | + * @throws \EE_Error |
|
253 | + */ |
|
254 | + public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) |
|
255 | + { |
|
256 | + EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty); |
|
257 | + return $this->save_cart() ? true : false; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * get_cart_total_before_tax |
|
263 | + * |
|
264 | + * @access public |
|
265 | + * @return float |
|
266 | + * @throws \EE_Error |
|
267 | + */ |
|
268 | + public function get_cart_total_before_tax() |
|
269 | + { |
|
270 | + return $this->get_grand_total()->recalculate_pre_tax_total(); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * gets the total amount of tax paid for items in this cart |
|
276 | + * |
|
277 | + * @access public |
|
278 | + * @return float |
|
279 | + * @throws \EE_Error |
|
280 | + */ |
|
281 | + public function get_applied_taxes() |
|
282 | + { |
|
283 | + return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
289 | + * |
|
290 | + * @access public |
|
291 | + * @return float |
|
292 | + * @throws \EE_Error |
|
293 | + */ |
|
294 | + public function get_cart_grand_total() |
|
295 | + { |
|
296 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
297 | + return $this->get_grand_total()->total(); |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
303 | + * |
|
304 | + * @access public |
|
305 | + * @return float |
|
306 | + * @throws \EE_Error |
|
307 | + */ |
|
308 | + public function recalculate_all_cart_totals() |
|
309 | + { |
|
310 | + $pre_tax_total = $this->get_cart_total_before_tax(); |
|
311 | + $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
312 | + $this->_grand_total->set_total($pre_tax_total + $taxes_total); |
|
313 | + $this->_grand_total->save_this_and_descendants_to_txn(); |
|
314 | + return $this->get_grand_total()->total(); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * deletes an item from the cart |
|
320 | + * |
|
321 | + * @access public |
|
322 | + * @param array|bool|string $line_item_codes |
|
323 | + * @return int on success, FALSE on fail |
|
324 | + * @throws \EE_Error |
|
325 | + */ |
|
326 | + public function delete_items($line_item_codes = false) |
|
327 | + { |
|
328 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
329 | + return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
330 | + } |
|
331 | + |
|
332 | + |
|
333 | + /** |
|
334 | + * @remove ALL items from cart and zero ALL totals |
|
335 | + * @access public |
|
336 | + * @return bool |
|
337 | + * @throws \EE_Error |
|
338 | + */ |
|
339 | + public function empty_cart() |
|
340 | + { |
|
341 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
342 | + $this->_grand_total = $this->_create_grand_total(); |
|
343 | + return $this->save_cart(true); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @remove ALL items from cart and delete total as well |
|
349 | + * @access public |
|
350 | + * @return bool |
|
351 | + * @throws \EE_Error |
|
352 | + */ |
|
353 | + public function delete_cart() |
|
354 | + { |
|
355 | + if ($this->_grand_total instanceof EE_Line_Item) { |
|
356 | + $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total); |
|
357 | + if ($deleted) { |
|
358 | + $deleted += $this->_grand_total->delete(); |
|
359 | + $this->_grand_total = null; |
|
360 | + return true; |
|
361 | + } |
|
362 | + } |
|
363 | + return false; |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @save cart to session |
|
369 | + * @access public |
|
370 | + * @param bool $apply_taxes |
|
371 | + * @return TRUE on success, FALSE on fail |
|
372 | + * @throws \EE_Error |
|
373 | + */ |
|
374 | + public function save_cart($apply_taxes = true) |
|
375 | + { |
|
376 | + if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) { |
|
377 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
378 | + // make sure we don't cache the transaction because it can get stale |
|
379 | + if ( |
|
380 | + $this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction |
|
381 | + && $this->_grand_total->get_one_from_cache('Transaction')->ID() |
|
382 | + ) { |
|
383 | + $this->_grand_total->clear_cache('Transaction', null, true); |
|
384 | + } |
|
385 | + } |
|
386 | + if ($this->session() instanceof EE_Session) { |
|
387 | + return $this->session()->set_cart($this); |
|
388 | + } else { |
|
389 | + return false; |
|
390 | + } |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + public function __wakeup() |
|
395 | + { |
|
396 | + if (! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
397 | + // $this->_grand_total is actually just an ID, so use it to get the object from the db |
|
398 | + $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * @return array |
|
405 | + */ |
|
406 | + public function __sleep() |
|
407 | + { |
|
408 | + if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) { |
|
409 | + $this->_grand_total = $this->_grand_total->ID(); |
|
410 | + } |
|
411 | + return array('_grand_total'); |
|
412 | + } |
|
413 | 413 | } |
@@ -13,27 +13,27 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @deprecated |
|
18 | - * @param EE_Request $request |
|
19 | - * @param EE_Response $response |
|
20 | - * @return EE_Response |
|
21 | - */ |
|
22 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
23 | - { |
|
24 | - EE_Error::doing_it_wrong( |
|
25 | - __METHOD__, |
|
26 | - sprintf( |
|
27 | - esc_html__( |
|
28 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - 'EventEspresso\core\services\request\middleware\DetectLogin', |
|
32 | - '\core\services\request', |
|
33 | - 'EventEspresso\core\services\request' |
|
34 | - ), |
|
35 | - '4.9.52' |
|
36 | - ); |
|
37 | - return $response; |
|
38 | - } |
|
16 | + /** |
|
17 | + * @deprecated |
|
18 | + * @param EE_Request $request |
|
19 | + * @param EE_Response $response |
|
20 | + * @return EE_Response |
|
21 | + */ |
|
22 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
23 | + { |
|
24 | + EE_Error::doing_it_wrong( |
|
25 | + __METHOD__, |
|
26 | + sprintf( |
|
27 | + esc_html__( |
|
28 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + 'EventEspresso\core\services\request\middleware\DetectLogin', |
|
32 | + '\core\services\request', |
|
33 | + 'EventEspresso\core\services\request' |
|
34 | + ), |
|
35 | + '4.9.52' |
|
36 | + ); |
|
37 | + return $response; |
|
38 | + } |
|
39 | 39 | } |
@@ -17,75 +17,75 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @deprecated |
|
22 | - * @param EE_Request $request |
|
23 | - * @param EE_Response $response |
|
24 | - * @return EE_Response |
|
25 | - */ |
|
26 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
27 | - { |
|
28 | - EE_Error::doing_it_wrong( |
|
29 | - __METHOD__, |
|
30 | - sprintf( |
|
31 | - esc_html__( |
|
32 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions', |
|
36 | - '\core\services\request', |
|
37 | - 'EventEspresso\core\services\request' |
|
38 | - ), |
|
39 | - '4.9.52' |
|
40 | - ); |
|
41 | - return $response; |
|
42 | - } |
|
20 | + /** |
|
21 | + * @deprecated |
|
22 | + * @param EE_Request $request |
|
23 | + * @param EE_Response $response |
|
24 | + * @return EE_Response |
|
25 | + */ |
|
26 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
27 | + { |
|
28 | + EE_Error::doing_it_wrong( |
|
29 | + __METHOD__, |
|
30 | + sprintf( |
|
31 | + esc_html__( |
|
32 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions', |
|
36 | + '\core\services\request', |
|
37 | + 'EventEspresso\core\services\request' |
|
38 | + ), |
|
39 | + '4.9.52' |
|
40 | + ); |
|
41 | + return $response; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @deprecated |
|
47 | - * @param string $version_to_check |
|
48 | - * @param string $operator |
|
49 | - * @return bool |
|
50 | - */ |
|
51 | - public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
52 | - { |
|
53 | - EE_Error::doing_it_wrong( |
|
54 | - __METHOD__, |
|
55 | - sprintf( |
|
56 | - esc_html__( |
|
57 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
58 | - 'event_espresso' |
|
59 | - ), |
|
60 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions::compareWordPressVersion()', |
|
61 | - '\core\services\request', |
|
62 | - 'EventEspresso\core\services\request' |
|
63 | - ), |
|
64 | - '4.9.52', |
|
65 | - '5.0.0' |
|
66 | - ); |
|
67 | - return RecommendedVersions::compareWordPressVersion($version_to_check, $operator); |
|
68 | - } |
|
45 | + /** |
|
46 | + * @deprecated |
|
47 | + * @param string $version_to_check |
|
48 | + * @param string $operator |
|
49 | + * @return bool |
|
50 | + */ |
|
51 | + public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
52 | + { |
|
53 | + EE_Error::doing_it_wrong( |
|
54 | + __METHOD__, |
|
55 | + sprintf( |
|
56 | + esc_html__( |
|
57 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
58 | + 'event_espresso' |
|
59 | + ), |
|
60 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions::compareWordPressVersion()', |
|
61 | + '\core\services\request', |
|
62 | + 'EventEspresso\core\services\request' |
|
63 | + ), |
|
64 | + '4.9.52', |
|
65 | + '5.0.0' |
|
66 | + ); |
|
67 | + return RecommendedVersions::compareWordPressVersion($version_to_check, $operator); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @deprecated |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public function minimum_wp_version_error() |
|
76 | - { |
|
77 | - EE_Error::doing_it_wrong( |
|
78 | - __METHOD__, |
|
79 | - sprintf( |
|
80 | - esc_html__( |
|
81 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
82 | - 'event_espresso' |
|
83 | - ), |
|
84 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions::minimumWpVersionError()', |
|
85 | - '\core\services\request', |
|
86 | - 'EventEspresso\core\services\request' |
|
87 | - ), |
|
88 | - '4.9.52' |
|
89 | - ); |
|
90 | - } |
|
71 | + /** |
|
72 | + * @deprecated |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public function minimum_wp_version_error() |
|
76 | + { |
|
77 | + EE_Error::doing_it_wrong( |
|
78 | + __METHOD__, |
|
79 | + sprintf( |
|
80 | + esc_html__( |
|
81 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
82 | + 'event_espresso' |
|
83 | + ), |
|
84 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions::minimumWpVersionError()', |
|
85 | + '\core\services\request', |
|
86 | + 'EventEspresso\core\services\request' |
|
87 | + ), |
|
88 | + '4.9.52' |
|
89 | + ); |
|
90 | + } |
|
91 | 91 | } |
@@ -20,27 +20,27 @@ |
||
20 | 20 | abstract class EE_Middleware implements EEI_Request_Decorator |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @deprecated |
|
25 | - * @param EE_Request $request |
|
26 | - * @param EE_Response $response |
|
27 | - * @return EE_Response |
|
28 | - */ |
|
29 | - protected function process_request_stack(EE_Request $request, EE_Response $response) |
|
30 | - { |
|
31 | - EE_Error::doing_it_wrong( |
|
32 | - __METHOD__, |
|
33 | - sprintf( |
|
34 | - esc_html__( |
|
35 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - 'EventEspresso\core\services\request\middleware\Middleware', |
|
39 | - '\core\services\request', |
|
40 | - 'EventEspresso\core\services\request' |
|
41 | - ), |
|
42 | - '4.9.52' |
|
43 | - ); |
|
44 | - return $response; |
|
45 | - } |
|
23 | + /** |
|
24 | + * @deprecated |
|
25 | + * @param EE_Request $request |
|
26 | + * @param EE_Response $response |
|
27 | + * @return EE_Response |
|
28 | + */ |
|
29 | + protected function process_request_stack(EE_Request $request, EE_Response $response) |
|
30 | + { |
|
31 | + EE_Error::doing_it_wrong( |
|
32 | + __METHOD__, |
|
33 | + sprintf( |
|
34 | + esc_html__( |
|
35 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + 'EventEspresso\core\services\request\middleware\Middleware', |
|
39 | + '\core\services\request', |
|
40 | + 'EventEspresso\core\services\request' |
|
41 | + ), |
|
42 | + '4.9.52' |
|
43 | + ); |
|
44 | + return $response; |
|
45 | + } |
|
46 | 46 | } |
@@ -14,87 +14,87 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * @deprecated 4.9.53 |
|
19 | - * @param EE_Request $request |
|
20 | - * @param EE_Response $response |
|
21 | - * @return EE_Response |
|
22 | - */ |
|
23 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
24 | - { |
|
25 | - $this->_request = $request; |
|
26 | - $this->_response = $response; |
|
27 | - $this->display_alpha_banner_warning(); |
|
28 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
29 | - return $this->_response; |
|
30 | - } |
|
17 | + /** |
|
18 | + * @deprecated 4.9.53 |
|
19 | + * @param EE_Request $request |
|
20 | + * @param EE_Response $response |
|
21 | + * @return EE_Response |
|
22 | + */ |
|
23 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
24 | + { |
|
25 | + $this->_request = $request; |
|
26 | + $this->_response = $response; |
|
27 | + $this->display_alpha_banner_warning(); |
|
28 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
29 | + return $this->_response; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @deprecated |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function display_alpha_banner_warning() |
|
38 | - { |
|
39 | - EE_Error::doing_it_wrong( |
|
40 | - __METHOD__, |
|
41 | - sprintf( |
|
42 | - esc_html__( |
|
43 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::displayPreProductionVersionWarning()', |
|
47 | - '\core\services\request', |
|
48 | - 'EventEspresso\core\services\request' |
|
49 | - ), |
|
50 | - '4.9.52', |
|
51 | - '4.10.0' |
|
52 | - ); |
|
53 | - } |
|
33 | + /** |
|
34 | + * @deprecated |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function display_alpha_banner_warning() |
|
38 | + { |
|
39 | + EE_Error::doing_it_wrong( |
|
40 | + __METHOD__, |
|
41 | + sprintf( |
|
42 | + esc_html__( |
|
43 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::displayPreProductionVersionWarning()', |
|
47 | + '\core\services\request', |
|
48 | + 'EventEspresso\core\services\request' |
|
49 | + ), |
|
50 | + '4.9.52', |
|
51 | + '4.10.0' |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @deprecated |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function alpha_banner_admin_notice() |
|
61 | - { |
|
62 | - EE_Error::doing_it_wrong( |
|
63 | - __METHOD__, |
|
64 | - sprintf( |
|
65 | - esc_html__( |
|
66 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
67 | - 'event_espresso' |
|
68 | - ), |
|
69 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionAdminNotice()', |
|
70 | - '\core\services\request', |
|
71 | - 'EventEspresso\core\services\request' |
|
72 | - ), |
|
73 | - '4.9.52', |
|
74 | - '4.10.0' |
|
75 | - ); |
|
76 | - } |
|
56 | + /** |
|
57 | + * @deprecated |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function alpha_banner_admin_notice() |
|
61 | + { |
|
62 | + EE_Error::doing_it_wrong( |
|
63 | + __METHOD__, |
|
64 | + sprintf( |
|
65 | + esc_html__( |
|
66 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
67 | + 'event_espresso' |
|
68 | + ), |
|
69 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionAdminNotice()', |
|
70 | + '\core\services\request', |
|
71 | + 'EventEspresso\core\services\request' |
|
72 | + ), |
|
73 | + '4.9.52', |
|
74 | + '4.10.0' |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @deprecated |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function alpha_banner_warning_notice() |
|
84 | - { |
|
85 | - EE_Error::doing_it_wrong( |
|
86 | - __METHOD__, |
|
87 | - sprintf( |
|
88 | - esc_html__( |
|
89 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
90 | - 'event_espresso' |
|
91 | - ), |
|
92 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionWarningNotice()', |
|
93 | - '\core\services\request', |
|
94 | - 'EventEspresso\core\services\request' |
|
95 | - ), |
|
96 | - '4.9.52', |
|
97 | - '4.10.0' |
|
98 | - ); |
|
99 | - } |
|
79 | + /** |
|
80 | + * @deprecated |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function alpha_banner_warning_notice() |
|
84 | + { |
|
85 | + EE_Error::doing_it_wrong( |
|
86 | + __METHOD__, |
|
87 | + sprintf( |
|
88 | + esc_html__( |
|
89 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
90 | + 'event_espresso' |
|
91 | + ), |
|
92 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionWarningNotice()', |
|
93 | + '\core\services\request', |
|
94 | + 'EventEspresso\core\services\request' |
|
95 | + ), |
|
96 | + '4.9.52', |
|
97 | + '4.10.0' |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | } |
@@ -14,78 +14,78 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * load_espresso_addons |
|
19 | - * runs during the WP 'plugins_loaded' action at priority 1 |
|
20 | - * and is the initial loading phase for EE addons |
|
21 | - * no other logic should be performed at this point |
|
22 | - */ |
|
23 | - public static function load_espresso_addons() |
|
24 | - { |
|
25 | - do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
26 | - } |
|
17 | + /** |
|
18 | + * load_espresso_addons |
|
19 | + * runs during the WP 'plugins_loaded' action at priority 1 |
|
20 | + * and is the initial loading phase for EE addons |
|
21 | + * no other logic should be performed at this point |
|
22 | + */ |
|
23 | + public static function load_espresso_addons() |
|
24 | + { |
|
25 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * detect_activations_or_upgrades |
|
31 | - * runs during the WP 'plugins_loaded' action at priority 3 |
|
32 | - * Now that all of the addons have been loaded, |
|
33 | - * we can determine if anything needs activating or upgrading |
|
34 | - */ |
|
35 | - public static function detect_activations_or_upgrades() |
|
36 | - { |
|
37 | - do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
38 | - } |
|
29 | + /** |
|
30 | + * detect_activations_or_upgrades |
|
31 | + * runs during the WP 'plugins_loaded' action at priority 3 |
|
32 | + * Now that all of the addons have been loaded, |
|
33 | + * we can determine if anything needs activating or upgrading |
|
34 | + */ |
|
35 | + public static function detect_activations_or_upgrades() |
|
36 | + { |
|
37 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * load_core_configuration |
|
43 | - * runs during the WP 'plugins_loaded' action at priority 5 |
|
44 | - * Now that the database is assumed to be at the correct version |
|
45 | - * we can load and set all of the system configurations |
|
46 | - */ |
|
47 | - public static function load_core_configuration() |
|
48 | - { |
|
49 | - do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
50 | - } |
|
41 | + /** |
|
42 | + * load_core_configuration |
|
43 | + * runs during the WP 'plugins_loaded' action at priority 5 |
|
44 | + * Now that the database is assumed to be at the correct version |
|
45 | + * we can load and set all of the system configurations |
|
46 | + */ |
|
47 | + public static function load_core_configuration() |
|
48 | + { |
|
49 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * register_shortcodes_modules_and_widgets |
|
55 | - * runs during the WP 'plugins_loaded' action at priority 7 |
|
56 | - * and handles registering all o four shortcodes, modules and widgets |
|
57 | - * so that they are ready to be used throughout the system |
|
58 | - */ |
|
59 | - public static function register_shortcodes_modules_and_widgets() |
|
60 | - { |
|
61 | - do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
62 | - } |
|
53 | + /** |
|
54 | + * register_shortcodes_modules_and_widgets |
|
55 | + * runs during the WP 'plugins_loaded' action at priority 7 |
|
56 | + * and handles registering all o four shortcodes, modules and widgets |
|
57 | + * so that they are ready to be used throughout the system |
|
58 | + */ |
|
59 | + public static function register_shortcodes_modules_and_widgets() |
|
60 | + { |
|
61 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * brew_espresso |
|
67 | - * runs during the WP 'plugins_loaded' action at priority 9 |
|
68 | - * bootstrapping is considered complete at this point, |
|
69 | - * so let the fun begin... |
|
70 | - */ |
|
71 | - public static function brew_espresso() |
|
72 | - { |
|
73 | - do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
74 | - } |
|
65 | + /** |
|
66 | + * brew_espresso |
|
67 | + * runs during the WP 'plugins_loaded' action at priority 9 |
|
68 | + * bootstrapping is considered complete at this point, |
|
69 | + * so let the fun begin... |
|
70 | + */ |
|
71 | + public static function brew_espresso() |
|
72 | + { |
|
73 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @deprecated 4.9.53 |
|
79 | - */ |
|
80 | - public function run_request_stack() |
|
81 | - { |
|
82 | - } |
|
77 | + /** |
|
78 | + * @deprecated 4.9.53 |
|
79 | + */ |
|
80 | + public function run_request_stack() |
|
81 | + { |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @deprecated 4.9.53 |
|
87 | - */ |
|
88 | - public function build_request_stack() |
|
89 | - { |
|
90 | - } |
|
85 | + /** |
|
86 | + * @deprecated 4.9.53 |
|
87 | + */ |
|
88 | + public function build_request_stack() |
|
89 | + { |
|
90 | + } |
|
91 | 91 | } |