@@ -16,222 +16,222 @@ |
||
16 | 16 | class Price_Types_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | 18 | |
19 | - public function __construct($admin_page) |
|
20 | - { |
|
21 | - parent::__construct($admin_page); |
|
22 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
23 | - $this->_PRT = EEM_Price_Type::instance(); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _setup_data() |
|
28 | - { |
|
29 | - $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
30 | - $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed); |
|
31 | - $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false); |
|
32 | - $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - protected function _set_properties() |
|
37 | - { |
|
38 | - $this->_wp_list_args = array( |
|
39 | - 'singular' => esc_html__('price type', 'event_espresso'), |
|
40 | - 'plural' => esc_html__('price types', 'event_espresso'), |
|
41 | - 'ajax' => true, |
|
42 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
43 | - ); |
|
44 | - |
|
45 | - $this->_columns = array( |
|
46 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
47 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
48 | - 'base_type' => '<div class="jst-cntr">' . esc_html__('Base Type', 'event_espresso') . '</div>', |
|
49 | - 'percent' => '<div class="jst-cntr">' |
|
50 | - . sprintf( |
|
51 | - /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */ |
|
52 | - esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'), |
|
53 | - '<br/>', |
|
54 | - '<span class="big-text">', |
|
55 | - '</span>' |
|
56 | - ) |
|
57 | - . '</div>', |
|
58 | - 'order' => '<div class="jst-cntr">' |
|
59 | - . sprintf( |
|
60 | - /* translators: HTML new line */ |
|
61 | - esc_html__('Order of %s Application', 'event_espresso'), |
|
62 | - '<br/>' |
|
63 | - ) |
|
64 | - . '</div>', |
|
65 | - ); |
|
66 | - |
|
67 | - $this->_sortable_columns = array( |
|
68 | - // TRUE means its already sorted |
|
69 | - 'name' => array('name' => false), |
|
70 | - ); |
|
71 | - |
|
72 | - $this->_hidden_columns = array(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - protected function _get_table_filters() |
|
77 | - { |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - protected function _add_view_counts() |
|
82 | - { |
|
83 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
84 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
85 | - 'ee_delete_default_price_types', |
|
86 | - 'pricing_trash_price_type' |
|
87 | - )) { |
|
88 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - public function column_cb($item) |
|
94 | - { |
|
95 | - if ($item->base_type() !== 1) { |
|
96 | - return sprintf( |
|
97 | - '<input type="checkbox" name="checkbox[%1$s]" />', |
|
98 | - $item->ID() |
|
99 | - ); |
|
100 | - } |
|
101 | - return ''; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - public function column_name($item) |
|
106 | - { |
|
107 | - |
|
108 | - // Build row actions |
|
109 | - $actions = array(); |
|
110 | - // edit price link |
|
111 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
112 | - 'ee_edit_default_price_type', |
|
113 | - 'pricing_edit_price_type', |
|
114 | - $item->ID() |
|
115 | - )) { |
|
116 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
117 | - 'action' => 'edit_price_type', |
|
118 | - 'id' => $item->ID(), |
|
119 | - ), PRICING_ADMIN_URL); |
|
120 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="' |
|
121 | - . sprintf( |
|
122 | - /* translators: The name of the price type */ |
|
123 | - esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
124 | - $item->name() |
|
125 | - ) |
|
126 | - . '">' |
|
127 | - . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
128 | - } |
|
129 | - |
|
130 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
131 | - 'ee_edit_default_price_type', |
|
132 | - 'pricing_edit_price_type', |
|
133 | - $item->ID() |
|
134 | - ) |
|
135 | - ? '<a href="' . $edit_lnk_url . '" aria-label="' |
|
136 | - . sprintf( |
|
137 | - /* translators: The name of the price type */ |
|
138 | - esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
139 | - $item->name() |
|
140 | - ) |
|
141 | - . '">' |
|
142 | - . stripslashes($item->name()) . '</a>' |
|
143 | - : $item->name(); |
|
144 | - |
|
145 | - if ($item->base_type() !== 1) { |
|
146 | - if ($this->_view == 'all') { |
|
147 | - // trash price link |
|
148 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
149 | - 'ee_delete_default_price_type', |
|
150 | - 'pricing_trash_price_type', |
|
151 | - $item->ID() |
|
152 | - )) { |
|
153 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
154 | - 'action' => 'trash_price_type', |
|
155 | - 'id' => $item->ID(), |
|
156 | - 'noheader' => true, |
|
157 | - ), PRICING_ADMIN_URL); |
|
158 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
159 | - . sprintf( |
|
160 | - /* translators: The name of the price type */ |
|
161 | - esc_attr__('Move Price Type %s to Trash', 'event_espresso'), |
|
162 | - $item->name() |
|
163 | - ) |
|
164 | - . '">' |
|
165 | - . esc_html__('Move to Trash', 'event_espresso') . '</a>'; |
|
166 | - } |
|
167 | - } else { |
|
168 | - // restore price link |
|
169 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
170 | - 'ee_delete_default_price_type', |
|
171 | - 'pricing_restore_price_type', |
|
172 | - $item->ID() |
|
173 | - )) { |
|
174 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
175 | - 'action' => 'restore_price_type', |
|
176 | - 'id' => $item->ID(), |
|
177 | - 'noheader' => true, |
|
178 | - ), PRICING_ADMIN_URL); |
|
179 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
180 | - . sprintf( |
|
181 | - /* translators: The name of the price type */ |
|
182 | - esc_attr__('Restore Price Type (%s)', 'event_espresso'), |
|
183 | - $item->name() |
|
184 | - ) |
|
185 | - . '">' |
|
186 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
187 | - } |
|
188 | - // delete price link |
|
189 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
190 | - 'ee_delete_default_price_type', |
|
191 | - 'pricing_delete_price_type', |
|
192 | - $item->ID() |
|
193 | - )) { |
|
194 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
195 | - 'action' => 'delete_price_type', |
|
196 | - 'id' => $item->ID(), |
|
197 | - 'noheader' => true, |
|
198 | - ), PRICING_ADMIN_URL); |
|
199 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
200 | - . sprintf( |
|
201 | - /* translators: The name of the price type */ |
|
202 | - esc_attr__('Delete Price Type %s Permanently', 'event_espresso'), |
|
203 | - $item->name() |
|
204 | - ) |
|
205 | - . '">' |
|
206 | - . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - // Return the name contents |
|
212 | - return sprintf( |
|
213 | - '%1$s <span style="color:silver">(id:%2$s)</span>%3$s', |
|
214 | - $name_link, |
|
215 | - $item->ID(), |
|
216 | - $this->row_actions($actions) |
|
217 | - ); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - public function column_base_type($item) |
|
222 | - { |
|
223 | - return '<div class="jst-cntr">' . $item->base_type_name() . '</div>'; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - public function column_percent($item) |
|
228 | - { |
|
229 | - return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>'; |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - public function column_order($item) |
|
234 | - { |
|
235 | - return '<div class="jst-cntr">' . $item->order() . '</div>'; |
|
236 | - } |
|
19 | + public function __construct($admin_page) |
|
20 | + { |
|
21 | + parent::__construct($admin_page); |
|
22 | + require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
23 | + $this->_PRT = EEM_Price_Type::instance(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _setup_data() |
|
28 | + { |
|
29 | + $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
30 | + $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed); |
|
31 | + $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false); |
|
32 | + $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + protected function _set_properties() |
|
37 | + { |
|
38 | + $this->_wp_list_args = array( |
|
39 | + 'singular' => esc_html__('price type', 'event_espresso'), |
|
40 | + 'plural' => esc_html__('price types', 'event_espresso'), |
|
41 | + 'ajax' => true, |
|
42 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
43 | + ); |
|
44 | + |
|
45 | + $this->_columns = array( |
|
46 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
47 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
48 | + 'base_type' => '<div class="jst-cntr">' . esc_html__('Base Type', 'event_espresso') . '</div>', |
|
49 | + 'percent' => '<div class="jst-cntr">' |
|
50 | + . sprintf( |
|
51 | + /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */ |
|
52 | + esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'), |
|
53 | + '<br/>', |
|
54 | + '<span class="big-text">', |
|
55 | + '</span>' |
|
56 | + ) |
|
57 | + . '</div>', |
|
58 | + 'order' => '<div class="jst-cntr">' |
|
59 | + . sprintf( |
|
60 | + /* translators: HTML new line */ |
|
61 | + esc_html__('Order of %s Application', 'event_espresso'), |
|
62 | + '<br/>' |
|
63 | + ) |
|
64 | + . '</div>', |
|
65 | + ); |
|
66 | + |
|
67 | + $this->_sortable_columns = array( |
|
68 | + // TRUE means its already sorted |
|
69 | + 'name' => array('name' => false), |
|
70 | + ); |
|
71 | + |
|
72 | + $this->_hidden_columns = array(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + protected function _get_table_filters() |
|
77 | + { |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + protected function _add_view_counts() |
|
82 | + { |
|
83 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
84 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
85 | + 'ee_delete_default_price_types', |
|
86 | + 'pricing_trash_price_type' |
|
87 | + )) { |
|
88 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + public function column_cb($item) |
|
94 | + { |
|
95 | + if ($item->base_type() !== 1) { |
|
96 | + return sprintf( |
|
97 | + '<input type="checkbox" name="checkbox[%1$s]" />', |
|
98 | + $item->ID() |
|
99 | + ); |
|
100 | + } |
|
101 | + return ''; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + public function column_name($item) |
|
106 | + { |
|
107 | + |
|
108 | + // Build row actions |
|
109 | + $actions = array(); |
|
110 | + // edit price link |
|
111 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
112 | + 'ee_edit_default_price_type', |
|
113 | + 'pricing_edit_price_type', |
|
114 | + $item->ID() |
|
115 | + )) { |
|
116 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
117 | + 'action' => 'edit_price_type', |
|
118 | + 'id' => $item->ID(), |
|
119 | + ), PRICING_ADMIN_URL); |
|
120 | + $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="' |
|
121 | + . sprintf( |
|
122 | + /* translators: The name of the price type */ |
|
123 | + esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
124 | + $item->name() |
|
125 | + ) |
|
126 | + . '">' |
|
127 | + . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
128 | + } |
|
129 | + |
|
130 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
131 | + 'ee_edit_default_price_type', |
|
132 | + 'pricing_edit_price_type', |
|
133 | + $item->ID() |
|
134 | + ) |
|
135 | + ? '<a href="' . $edit_lnk_url . '" aria-label="' |
|
136 | + . sprintf( |
|
137 | + /* translators: The name of the price type */ |
|
138 | + esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
139 | + $item->name() |
|
140 | + ) |
|
141 | + . '">' |
|
142 | + . stripslashes($item->name()) . '</a>' |
|
143 | + : $item->name(); |
|
144 | + |
|
145 | + if ($item->base_type() !== 1) { |
|
146 | + if ($this->_view == 'all') { |
|
147 | + // trash price link |
|
148 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
149 | + 'ee_delete_default_price_type', |
|
150 | + 'pricing_trash_price_type', |
|
151 | + $item->ID() |
|
152 | + )) { |
|
153 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
154 | + 'action' => 'trash_price_type', |
|
155 | + 'id' => $item->ID(), |
|
156 | + 'noheader' => true, |
|
157 | + ), PRICING_ADMIN_URL); |
|
158 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
159 | + . sprintf( |
|
160 | + /* translators: The name of the price type */ |
|
161 | + esc_attr__('Move Price Type %s to Trash', 'event_espresso'), |
|
162 | + $item->name() |
|
163 | + ) |
|
164 | + . '">' |
|
165 | + . esc_html__('Move to Trash', 'event_espresso') . '</a>'; |
|
166 | + } |
|
167 | + } else { |
|
168 | + // restore price link |
|
169 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
170 | + 'ee_delete_default_price_type', |
|
171 | + 'pricing_restore_price_type', |
|
172 | + $item->ID() |
|
173 | + )) { |
|
174 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
175 | + 'action' => 'restore_price_type', |
|
176 | + 'id' => $item->ID(), |
|
177 | + 'noheader' => true, |
|
178 | + ), PRICING_ADMIN_URL); |
|
179 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
180 | + . sprintf( |
|
181 | + /* translators: The name of the price type */ |
|
182 | + esc_attr__('Restore Price Type (%s)', 'event_espresso'), |
|
183 | + $item->name() |
|
184 | + ) |
|
185 | + . '">' |
|
186 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
187 | + } |
|
188 | + // delete price link |
|
189 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
190 | + 'ee_delete_default_price_type', |
|
191 | + 'pricing_delete_price_type', |
|
192 | + $item->ID() |
|
193 | + )) { |
|
194 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
195 | + 'action' => 'delete_price_type', |
|
196 | + 'id' => $item->ID(), |
|
197 | + 'noheader' => true, |
|
198 | + ), PRICING_ADMIN_URL); |
|
199 | + $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
200 | + . sprintf( |
|
201 | + /* translators: The name of the price type */ |
|
202 | + esc_attr__('Delete Price Type %s Permanently', 'event_espresso'), |
|
203 | + $item->name() |
|
204 | + ) |
|
205 | + . '">' |
|
206 | + . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + // Return the name contents |
|
212 | + return sprintf( |
|
213 | + '%1$s <span style="color:silver">(id:%2$s)</span>%3$s', |
|
214 | + $name_link, |
|
215 | + $item->ID(), |
|
216 | + $this->row_actions($actions) |
|
217 | + ); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + public function column_base_type($item) |
|
222 | + { |
|
223 | + return '<div class="jst-cntr">' . $item->base_type_name() . '</div>'; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + public function column_percent($item) |
|
228 | + { |
|
229 | + return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>'; |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + public function column_order($item) |
|
234 | + { |
|
235 | + return '<div class="jst-cntr">' . $item->order() . '</div>'; |
|
236 | + } |
|
237 | 237 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct($admin_page) |
20 | 20 | { |
21 | 21 | parent::__construct($admin_page); |
22 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
22 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
23 | 23 | $this->_PRT = EEM_Price_Type::instance(); |
24 | 24 | } |
25 | 25 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $this->_columns = array( |
46 | 46 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
47 | 47 | 'name' => esc_html__('Name', 'event_espresso'), |
48 | - 'base_type' => '<div class="jst-cntr">' . esc_html__('Base Type', 'event_espresso') . '</div>', |
|
48 | + 'base_type' => '<div class="jst-cntr">'.esc_html__('Base Type', 'event_espresso').'</div>', |
|
49 | 49 | 'percent' => '<div class="jst-cntr">' |
50 | 50 | . sprintf( |
51 | 51 | /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */ |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | 'action' => 'edit_price_type', |
118 | 118 | 'id' => $item->ID(), |
119 | 119 | ), PRICING_ADMIN_URL); |
120 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="' |
|
120 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" aria-label="' |
|
121 | 121 | . sprintf( |
122 | 122 | /* translators: The name of the price type */ |
123 | 123 | esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
124 | 124 | $item->name() |
125 | 125 | ) |
126 | 126 | . '">' |
127 | - . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
127 | + . esc_html__('Edit', 'event_espresso').'</a>'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $name_link = EE_Registry::instance()->CAP->current_user_can( |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | 'pricing_edit_price_type', |
133 | 133 | $item->ID() |
134 | 134 | ) |
135 | - ? '<a href="' . $edit_lnk_url . '" aria-label="' |
|
135 | + ? '<a href="'.$edit_lnk_url.'" aria-label="' |
|
136 | 136 | . sprintf( |
137 | 137 | /* translators: The name of the price type */ |
138 | 138 | esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
139 | 139 | $item->name() |
140 | 140 | ) |
141 | 141 | . '">' |
142 | - . stripslashes($item->name()) . '</a>' |
|
142 | + . stripslashes($item->name()).'</a>' |
|
143 | 143 | : $item->name(); |
144 | 144 | |
145 | 145 | if ($item->base_type() !== 1) { |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | 'id' => $item->ID(), |
156 | 156 | 'noheader' => true, |
157 | 157 | ), PRICING_ADMIN_URL); |
158 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
158 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" aria-label="' |
|
159 | 159 | . sprintf( |
160 | 160 | /* translators: The name of the price type */ |
161 | 161 | esc_attr__('Move Price Type %s to Trash', 'event_espresso'), |
162 | 162 | $item->name() |
163 | 163 | ) |
164 | 164 | . '">' |
165 | - . esc_html__('Move to Trash', 'event_espresso') . '</a>'; |
|
165 | + . esc_html__('Move to Trash', 'event_espresso').'</a>'; |
|
166 | 166 | } |
167 | 167 | } else { |
168 | 168 | // restore price link |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | 'id' => $item->ID(), |
177 | 177 | 'noheader' => true, |
178 | 178 | ), PRICING_ADMIN_URL); |
179 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
179 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" aria-label="' |
|
180 | 180 | . sprintf( |
181 | 181 | /* translators: The name of the price type */ |
182 | 182 | esc_attr__('Restore Price Type (%s)', 'event_espresso'), |
183 | 183 | $item->name() |
184 | 184 | ) |
185 | 185 | . '">' |
186 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
186 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
187 | 187 | } |
188 | 188 | // delete price link |
189 | 189 | if (EE_Registry::instance()->CAP->current_user_can( |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | 'id' => $item->ID(), |
197 | 197 | 'noheader' => true, |
198 | 198 | ), PRICING_ADMIN_URL); |
199 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
199 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" aria-label="' |
|
200 | 200 | . sprintf( |
201 | 201 | /* translators: The name of the price type */ |
202 | 202 | esc_attr__('Delete Price Type %s Permanently', 'event_espresso'), |
203 | 203 | $item->name() |
204 | 204 | ) |
205 | 205 | . '">' |
206 | - . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
206 | + . esc_html__('Delete Permanently', 'event_espresso').'</a>'; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | |
221 | 221 | public function column_base_type($item) |
222 | 222 | { |
223 | - return '<div class="jst-cntr">' . $item->base_type_name() . '</div>'; |
|
223 | + return '<div class="jst-cntr">'.$item->base_type_name().'</div>'; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | 227 | public function column_percent($item) |
228 | 228 | { |
229 | - return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>'; |
|
229 | + return '<div class="jst-cntr">'.($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign).'</div>'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
233 | 233 | public function column_order($item) |
234 | 234 | { |
235 | - return '<div class="jst-cntr">' . $item->order() . '</div>'; |
|
235 | + return '<div class="jst-cntr">'.$item->order().'</div>'; |
|
236 | 236 | } |
237 | 237 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param CommandInterface|CreateRegistrationCommand $command |
43 | - * @return mixed |
|
43 | + * @return \EE_Registration |
|
44 | 44 | * @throws OutOfRangeException |
45 | 45 | * @throws UnexpectedEntityException |
46 | 46 | * @throws EE_Error |
@@ -21,42 +21,42 @@ |
||
21 | 21 | class CreateRegistrationCommandHandler extends CommandHandler |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var CreateRegistrationService $registration_service |
|
26 | - */ |
|
27 | - private $registration_service; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * Command constructor |
|
32 | - * |
|
33 | - * @param CreateRegistrationService $registration_service |
|
34 | - */ |
|
35 | - public function __construct(CreateRegistrationService $registration_service) |
|
36 | - { |
|
37 | - $this->registration_service = $registration_service; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @param CommandInterface|CreateRegistrationCommand $command |
|
43 | - * @return mixed |
|
44 | - * @throws OutOfRangeException |
|
45 | - * @throws UnexpectedEntityException |
|
46 | - * @throws EE_Error |
|
47 | - * @throws InvalidEntityException |
|
48 | - */ |
|
49 | - public function handle(CommandInterface $command) |
|
50 | - { |
|
51 | - // now create a new registration for the ticket |
|
52 | - return $this->registration_service->create( |
|
53 | - $command->ticket()->get_related_event(), |
|
54 | - $command->transaction(), |
|
55 | - $command->ticket(), |
|
56 | - $command->ticketLineItem(), |
|
57 | - $command->regCount(), |
|
58 | - $command->regGroupSize(), |
|
59 | - $command->regStatus() |
|
60 | - ); |
|
61 | - } |
|
24 | + /** |
|
25 | + * @var CreateRegistrationService $registration_service |
|
26 | + */ |
|
27 | + private $registration_service; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * Command constructor |
|
32 | + * |
|
33 | + * @param CreateRegistrationService $registration_service |
|
34 | + */ |
|
35 | + public function __construct(CreateRegistrationService $registration_service) |
|
36 | + { |
|
37 | + $this->registration_service = $registration_service; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @param CommandInterface|CreateRegistrationCommand $command |
|
43 | + * @return mixed |
|
44 | + * @throws OutOfRangeException |
|
45 | + * @throws UnexpectedEntityException |
|
46 | + * @throws EE_Error |
|
47 | + * @throws InvalidEntityException |
|
48 | + */ |
|
49 | + public function handle(CommandInterface $command) |
|
50 | + { |
|
51 | + // now create a new registration for the ticket |
|
52 | + return $this->registration_service->create( |
|
53 | + $command->ticket()->get_related_event(), |
|
54 | + $command->transaction(), |
|
55 | + $command->ticket(), |
|
56 | + $command->ticketLineItem(), |
|
57 | + $command->regCount(), |
|
58 | + $command->regGroupSize(), |
|
59 | + $command->regStatus() |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @param CommandInterface|CreateTransactionCommand $command |
31 | - * @return mixed |
|
31 | + * @return EE_Transaction |
|
32 | 32 | * @throws EE_Error |
33 | 33 | * @throws InvalidEntityException |
34 | 34 | * @throws InvalidDataTypeException |
@@ -26,43 +26,43 @@ |
||
26 | 26 | class CreateTransactionCommandHandler extends CommandHandler |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @param CommandInterface|CreateTransactionCommand $command |
|
31 | - * @return mixed |
|
32 | - * @throws EE_Error |
|
33 | - * @throws InvalidEntityException |
|
34 | - * @throws InvalidDataTypeException |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - * @throws InvalidArgumentException |
|
37 | - * @throws ReflectionException |
|
38 | - * @throws RuntimeException |
|
39 | - */ |
|
40 | - public function handle(CommandInterface $command) |
|
41 | - { |
|
42 | - $transaction_details = $command->transactionDetails(); |
|
43 | - $cart_total = null; |
|
44 | - if ($command->checkout() instanceof EE_Checkout) { |
|
45 | - // ensure cart totals have been calculated |
|
46 | - $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
47 | - // grab the cart grand total |
|
48 | - $cart_total = $command->checkout()->cart->get_cart_grand_total(); |
|
49 | - $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array(); |
|
50 | - $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0; |
|
51 | - } |
|
52 | - // create new TXN and save it so it has an ID |
|
53 | - $transaction = EE_Transaction::new_instance($transaction_details); |
|
54 | - if (! $transaction instanceof EE_Transaction) { |
|
55 | - throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
|
56 | - } |
|
57 | - $transaction->save(); |
|
58 | - // ensure grand total line item created |
|
59 | - $cart_total = $cart_total instanceof EE_Line_Item |
|
60 | - ? $cart_total |
|
61 | - : EEH_Line_Item::create_total_line_item($transaction); |
|
62 | - if (! $cart_total instanceof EE_Line_Item) { |
|
63 | - throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
|
64 | - } |
|
65 | - $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
|
66 | - return $transaction; |
|
67 | - } |
|
29 | + /** |
|
30 | + * @param CommandInterface|CreateTransactionCommand $command |
|
31 | + * @return mixed |
|
32 | + * @throws EE_Error |
|
33 | + * @throws InvalidEntityException |
|
34 | + * @throws InvalidDataTypeException |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + * @throws InvalidArgumentException |
|
37 | + * @throws ReflectionException |
|
38 | + * @throws RuntimeException |
|
39 | + */ |
|
40 | + public function handle(CommandInterface $command) |
|
41 | + { |
|
42 | + $transaction_details = $command->transactionDetails(); |
|
43 | + $cart_total = null; |
|
44 | + if ($command->checkout() instanceof EE_Checkout) { |
|
45 | + // ensure cart totals have been calculated |
|
46 | + $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
47 | + // grab the cart grand total |
|
48 | + $cart_total = $command->checkout()->cart->get_cart_grand_total(); |
|
49 | + $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array(); |
|
50 | + $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0; |
|
51 | + } |
|
52 | + // create new TXN and save it so it has an ID |
|
53 | + $transaction = EE_Transaction::new_instance($transaction_details); |
|
54 | + if (! $transaction instanceof EE_Transaction) { |
|
55 | + throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
|
56 | + } |
|
57 | + $transaction->save(); |
|
58 | + // ensure grand total line item created |
|
59 | + $cart_total = $cart_total instanceof EE_Line_Item |
|
60 | + ? $cart_total |
|
61 | + : EEH_Line_Item::create_total_line_item($transaction); |
|
62 | + if (! $cart_total instanceof EE_Line_Item) { |
|
63 | + throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
|
64 | + } |
|
65 | + $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
|
66 | + return $transaction; |
|
67 | + } |
|
68 | 68 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | // create new TXN and save it so it has an ID |
53 | 53 | $transaction = EE_Transaction::new_instance($transaction_details); |
54 | - if (! $transaction instanceof EE_Transaction) { |
|
54 | + if ( ! $transaction instanceof EE_Transaction) { |
|
55 | 55 | throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
56 | 56 | } |
57 | 57 | $transaction->save(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $cart_total = $cart_total instanceof EE_Line_Item |
60 | 60 | ? $cart_total |
61 | 61 | : EEH_Line_Item::create_total_line_item($transaction); |
62 | - if (! $cart_total instanceof EE_Line_Item) { |
|
62 | + if ( ! $cart_total instanceof EE_Line_Item) { |
|
63 | 63 | throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
64 | 64 | } |
65 | 65 | $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
@@ -16,33 +16,33 @@ |
||
16 | 16 | class InvalidEntityException extends InvalidArgumentException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidEntityException constructor. |
|
21 | - * |
|
22 | - * @param mixed $actual the actual object (or thing) we got |
|
23 | - * @param string $expected classname of the entity we wanted |
|
24 | - * @param string $message |
|
25 | - * @param int $code |
|
26 | - * @param Exception $previous |
|
27 | - */ |
|
28 | - public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null) |
|
29 | - { |
|
30 | - if (empty($message)) { |
|
31 | - ob_start(); |
|
32 | - var_dump($actual); |
|
33 | - $object = ob_get_clean(); |
|
34 | - $message = sprintf( |
|
35 | - __( |
|
36 | - 'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - is_object($actual) |
|
40 | - ? get_class($actual) |
|
41 | - : gettype($actual), |
|
42 | - $expected, |
|
43 | - $object |
|
44 | - ); |
|
45 | - } |
|
46 | - parent::__construct($message, $code, $previous); |
|
47 | - } |
|
19 | + /** |
|
20 | + * InvalidEntityException constructor. |
|
21 | + * |
|
22 | + * @param mixed $actual the actual object (or thing) we got |
|
23 | + * @param string $expected classname of the entity we wanted |
|
24 | + * @param string $message |
|
25 | + * @param int $code |
|
26 | + * @param Exception $previous |
|
27 | + */ |
|
28 | + public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null) |
|
29 | + { |
|
30 | + if (empty($message)) { |
|
31 | + ob_start(); |
|
32 | + var_dump($actual); |
|
33 | + $object = ob_get_clean(); |
|
34 | + $message = sprintf( |
|
35 | + __( |
|
36 | + 'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + is_object($actual) |
|
40 | + ? get_class($actual) |
|
41 | + : gettype($actual), |
|
42 | + $expected, |
|
43 | + $object |
|
44 | + ); |
|
45 | + } |
|
46 | + parent::__construct($message, $code, $previous); |
|
47 | + } |
|
48 | 48 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | public function verify(CommandInterface $command) |
32 | 32 | { |
33 | 33 | $expected = str_replace('CommandHandler', 'Command', get_class($this)); |
34 | - if (! $command instanceof $expected) { |
|
34 | + if ( ! $command instanceof $expected) { |
|
35 | 35 | throw new InvalidEntityException($command, $expected); |
36 | 36 | } |
37 | 37 | return $this; |
@@ -14,26 +14,26 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class CommandHandler implements CommandHandlerInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Verifies the Command class matches the Handler class |
|
19 | - * by simply removing "Handler" from the Command class and then comparing. |
|
20 | - * IF the Command Handler has been changed via CommandHandlerManager::addCommandHandler, |
|
21 | - * or via the filter in CommandHandlerManager::getCommandHandler(), |
|
22 | - * then this method MUST be overridden in the new Command Handler class. |
|
23 | - * PLZ NOTE: that it also needs to return itself ($this) |
|
24 | - * because the CommandBus utilizes method chaining. |
|
25 | - * |
|
26 | - * @param CommandInterface $command |
|
27 | - * @return CommandHandler |
|
28 | - * @throws InvalidEntityException |
|
29 | - * @since 4.9.80.p |
|
30 | - */ |
|
31 | - public function verify(CommandInterface $command) |
|
32 | - { |
|
33 | - $expected = str_replace('CommandHandler', 'Command', get_class($this)); |
|
34 | - if (! $command instanceof $expected) { |
|
35 | - throw new InvalidEntityException($command, $expected); |
|
36 | - } |
|
37 | - return $this; |
|
38 | - } |
|
17 | + /** |
|
18 | + * Verifies the Command class matches the Handler class |
|
19 | + * by simply removing "Handler" from the Command class and then comparing. |
|
20 | + * IF the Command Handler has been changed via CommandHandlerManager::addCommandHandler, |
|
21 | + * or via the filter in CommandHandlerManager::getCommandHandler(), |
|
22 | + * then this method MUST be overridden in the new Command Handler class. |
|
23 | + * PLZ NOTE: that it also needs to return itself ($this) |
|
24 | + * because the CommandBus utilizes method chaining. |
|
25 | + * |
|
26 | + * @param CommandInterface $command |
|
27 | + * @return CommandHandler |
|
28 | + * @throws InvalidEntityException |
|
29 | + * @since 4.9.80.p |
|
30 | + */ |
|
31 | + public function verify(CommandInterface $command) |
|
32 | + { |
|
33 | + $expected = str_replace('CommandHandler', 'Command', get_class($this)); |
|
34 | + if (! $command instanceof $expected) { |
|
35 | + throw new InvalidEntityException($command, $expected); |
|
36 | + } |
|
37 | + return $this; |
|
38 | + } |
|
39 | 39 | } |
@@ -10,26 +10,26 @@ |
||
10 | 10 | interface CommandHandlerManagerInterface |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * !!! IMPORTANT !!! |
|
15 | - * If overriding the default CommandHandler for a Command, |
|
16 | - * be sure to also override CommandHandler::verify(), |
|
17 | - * or else an Exception will be thrown when the CommandBus |
|
18 | - * attempts to verify that the incoming Command matches the Handler |
|
19 | - * |
|
20 | - * @param CommandHandlerInterface $command_handler |
|
21 | - * @param string $fqcn_for_command Fully Qualified ClassName for Command |
|
22 | - * @return void |
|
23 | - * @throws InvalidCommandHandlerException |
|
24 | - */ |
|
25 | - public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = ''); |
|
13 | + /** |
|
14 | + * !!! IMPORTANT !!! |
|
15 | + * If overriding the default CommandHandler for a Command, |
|
16 | + * be sure to also override CommandHandler::verify(), |
|
17 | + * or else an Exception will be thrown when the CommandBus |
|
18 | + * attempts to verify that the incoming Command matches the Handler |
|
19 | + * |
|
20 | + * @param CommandHandlerInterface $command_handler |
|
21 | + * @param string $fqcn_for_command Fully Qualified ClassName for Command |
|
22 | + * @return void |
|
23 | + * @throws InvalidCommandHandlerException |
|
24 | + */ |
|
25 | + public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = ''); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param CommandInterface $command |
|
31 | - * @param CommandBusInterface $command_bus |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null); |
|
29 | + /** |
|
30 | + * @param CommandInterface $command |
|
31 | + * @param CommandBusInterface $command_bus |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null); |
|
35 | 35 | } |
@@ -23,36 +23,36 @@ |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
28 | - */ |
|
29 | - private $cancel_ticket_line_item_service; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * Command constructor |
|
34 | - * |
|
35 | - * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
36 | - */ |
|
37 | - public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
38 | - { |
|
39 | - $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @param CommandInterface|CancelTicketLineItemCommand $command |
|
45 | - * @return mixed |
|
46 | - * @throws InvalidEntityException |
|
47 | - * @throws RuntimeException |
|
48 | - */ |
|
49 | - public function handle(CommandInterface $command) |
|
50 | - { |
|
51 | - return $this->cancel_ticket_line_item_service->cancel( |
|
52 | - $command->transaction(), |
|
53 | - $command->ticket(), |
|
54 | - $command->quantity(), |
|
55 | - $command->ticketLineItem() |
|
56 | - ); |
|
57 | - } |
|
26 | + /** |
|
27 | + * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
28 | + */ |
|
29 | + private $cancel_ticket_line_item_service; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * Command constructor |
|
34 | + * |
|
35 | + * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
36 | + */ |
|
37 | + public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
38 | + { |
|
39 | + $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @param CommandInterface|CancelTicketLineItemCommand $command |
|
45 | + * @return mixed |
|
46 | + * @throws InvalidEntityException |
|
47 | + * @throws RuntimeException |
|
48 | + */ |
|
49 | + public function handle(CommandInterface $command) |
|
50 | + { |
|
51 | + return $this->cancel_ticket_line_item_service->cancel( |
|
52 | + $command->transaction(), |
|
53 | + $command->ticket(), |
|
54 | + $command->quantity(), |
|
55 | + $command->ticketLineItem() |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | } |
@@ -22,37 +22,37 @@ |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @var CreateTicketLineItemService $factory |
|
27 | - */ |
|
28 | - private $factory; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Command constructor |
|
33 | - * |
|
34 | - * @param CreateTicketLineItemService $factory |
|
35 | - */ |
|
36 | - public function __construct(CreateTicketLineItemService $factory) |
|
37 | - { |
|
38 | - $this->factory = $factory; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @param CommandInterface|CreateTicketLineItemCommand $command |
|
44 | - * @return EE_Line_Item |
|
45 | - * @throws InvalidEntityException |
|
46 | - * @throws UnexpectedEntityException |
|
47 | - * @throws EE_Error |
|
48 | - */ |
|
49 | - public function handle(CommandInterface $command) |
|
50 | - { |
|
51 | - // create new line item for ticket |
|
52 | - return $this->factory->create( |
|
53 | - $command->transaction(), |
|
54 | - $command->ticket(), |
|
55 | - $command->quantity() |
|
56 | - ); |
|
57 | - } |
|
25 | + /** |
|
26 | + * @var CreateTicketLineItemService $factory |
|
27 | + */ |
|
28 | + private $factory; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Command constructor |
|
33 | + * |
|
34 | + * @param CreateTicketLineItemService $factory |
|
35 | + */ |
|
36 | + public function __construct(CreateTicketLineItemService $factory) |
|
37 | + { |
|
38 | + $this->factory = $factory; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @param CommandInterface|CreateTicketLineItemCommand $command |
|
44 | + * @return EE_Line_Item |
|
45 | + * @throws InvalidEntityException |
|
46 | + * @throws UnexpectedEntityException |
|
47 | + * @throws EE_Error |
|
48 | + */ |
|
49 | + public function handle(CommandInterface $command) |
|
50 | + { |
|
51 | + // create new line item for ticket |
|
52 | + return $this->factory->create( |
|
53 | + $command->transaction(), |
|
54 | + $command->ticket(), |
|
55 | + $command->quantity() |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | } |
@@ -21,134 +21,134 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @var EEM_Attendee $attendee_model |
|
26 | - */ |
|
27 | - protected $attendee_model; |
|
24 | + /** |
|
25 | + * @var EEM_Attendee $attendee_model |
|
26 | + */ |
|
27 | + protected $attendee_model; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @param EEM_Attendee $attendee_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Attendee $attendee_model) |
|
34 | - { |
|
35 | - $this->attendee_model = $attendee_model; |
|
36 | - } |
|
30 | + /** |
|
31 | + * @param EEM_Attendee $attendee_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Attendee $attendee_model) |
|
34 | + { |
|
35 | + $this->attendee_model = $attendee_model; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param CommandInterface|CreateAttendeeCommand $command |
|
41 | - * @return EE_Attendee |
|
42 | - * @throws EE_Error |
|
43 | - * @throws InvalidEntityException |
|
44 | - */ |
|
45 | - public function handle(CommandInterface $command) |
|
46 | - { |
|
47 | - // have we met before? |
|
48 | - $attendee = $this->findExistingAttendee( |
|
49 | - $command->registration(), |
|
50 | - $command->attendeeDetails() |
|
51 | - ); |
|
52 | - // did we find an already existing record for this attendee ? |
|
53 | - if ($attendee instanceof EE_Attendee) { |
|
54 | - $attendee = $this->updateExistingAttendeeData( |
|
55 | - $attendee, |
|
56 | - $command->attendeeDetails() |
|
57 | - ); |
|
58 | - } else { |
|
59 | - $attendee = $this->createNewAttendee( |
|
60 | - $command->registration(), |
|
61 | - $command->attendeeDetails() |
|
62 | - ); |
|
63 | - } |
|
64 | - return $attendee; |
|
65 | - } |
|
39 | + /** |
|
40 | + * @param CommandInterface|CreateAttendeeCommand $command |
|
41 | + * @return EE_Attendee |
|
42 | + * @throws EE_Error |
|
43 | + * @throws InvalidEntityException |
|
44 | + */ |
|
45 | + public function handle(CommandInterface $command) |
|
46 | + { |
|
47 | + // have we met before? |
|
48 | + $attendee = $this->findExistingAttendee( |
|
49 | + $command->registration(), |
|
50 | + $command->attendeeDetails() |
|
51 | + ); |
|
52 | + // did we find an already existing record for this attendee ? |
|
53 | + if ($attendee instanceof EE_Attendee) { |
|
54 | + $attendee = $this->updateExistingAttendeeData( |
|
55 | + $attendee, |
|
56 | + $command->attendeeDetails() |
|
57 | + ); |
|
58 | + } else { |
|
59 | + $attendee = $this->createNewAttendee( |
|
60 | + $command->registration(), |
|
61 | + $command->attendeeDetails() |
|
62 | + ); |
|
63 | + } |
|
64 | + return $attendee; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * find_existing_attendee |
|
70 | - * |
|
71 | - * @param EE_Registration $registration |
|
72 | - * @param array $attendee_data |
|
73 | - * @return EE_Attendee |
|
74 | - */ |
|
75 | - private function findExistingAttendee(EE_Registration $registration, array $attendee_data) |
|
76 | - { |
|
77 | - $existing_attendee = null; |
|
78 | - // does this attendee already exist in the db ? |
|
79 | - // we're searching using a combination of first name, last name, AND email address |
|
80 | - $ATT_fname = ! empty($attendee_data['ATT_fname']) |
|
81 | - ? $attendee_data['ATT_fname'] |
|
82 | - : ''; |
|
83 | - $ATT_lname = ! empty($attendee_data['ATT_lname']) |
|
84 | - ? $attendee_data['ATT_lname'] |
|
85 | - : ''; |
|
86 | - $ATT_email = ! empty($attendee_data['ATT_email']) |
|
87 | - ? $attendee_data['ATT_email'] |
|
88 | - : ''; |
|
89 | - // but only if those have values |
|
90 | - if ($ATT_fname && $ATT_lname && $ATT_email) { |
|
91 | - $existing_attendee = $this->attendee_model->find_existing_attendee( |
|
92 | - array( |
|
93 | - 'ATT_fname' => $ATT_fname, |
|
94 | - 'ATT_lname' => $ATT_lname, |
|
95 | - 'ATT_email' => $ATT_email, |
|
96 | - ) |
|
97 | - ); |
|
98 | - } |
|
99 | - return apply_filters( |
|
100 | - 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
101 | - $existing_attendee, |
|
102 | - $registration, |
|
103 | - $attendee_data |
|
104 | - ); |
|
105 | - } |
|
68 | + /** |
|
69 | + * find_existing_attendee |
|
70 | + * |
|
71 | + * @param EE_Registration $registration |
|
72 | + * @param array $attendee_data |
|
73 | + * @return EE_Attendee |
|
74 | + */ |
|
75 | + private function findExistingAttendee(EE_Registration $registration, array $attendee_data) |
|
76 | + { |
|
77 | + $existing_attendee = null; |
|
78 | + // does this attendee already exist in the db ? |
|
79 | + // we're searching using a combination of first name, last name, AND email address |
|
80 | + $ATT_fname = ! empty($attendee_data['ATT_fname']) |
|
81 | + ? $attendee_data['ATT_fname'] |
|
82 | + : ''; |
|
83 | + $ATT_lname = ! empty($attendee_data['ATT_lname']) |
|
84 | + ? $attendee_data['ATT_lname'] |
|
85 | + : ''; |
|
86 | + $ATT_email = ! empty($attendee_data['ATT_email']) |
|
87 | + ? $attendee_data['ATT_email'] |
|
88 | + : ''; |
|
89 | + // but only if those have values |
|
90 | + if ($ATT_fname && $ATT_lname && $ATT_email) { |
|
91 | + $existing_attendee = $this->attendee_model->find_existing_attendee( |
|
92 | + array( |
|
93 | + 'ATT_fname' => $ATT_fname, |
|
94 | + 'ATT_lname' => $ATT_lname, |
|
95 | + 'ATT_email' => $ATT_email, |
|
96 | + ) |
|
97 | + ); |
|
98 | + } |
|
99 | + return apply_filters( |
|
100 | + 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
101 | + $existing_attendee, |
|
102 | + $registration, |
|
103 | + $attendee_data |
|
104 | + ); |
|
105 | + } |
|
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * _update_existing_attendee_data |
|
110 | - * in case it has changed since last time they registered for an event |
|
111 | - * |
|
112 | - * @param EE_Attendee $existing_attendee |
|
113 | - * @param array $attendee_data |
|
114 | - * @return EE_Attendee |
|
115 | - * @throws EE_Error |
|
116 | - */ |
|
117 | - private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data) |
|
118 | - { |
|
119 | - // first remove fname, lname, and email from attendee data |
|
120 | - // because these properties will be exactly the same as the returned attendee object, |
|
121 | - // since they were used in the query to get the attendee object in the first place |
|
122 | - $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
123 | - // now loop thru what's left and add to attendee CPT |
|
124 | - foreach ($attendee_data as $property_name => $property_value) { |
|
125 | - if (! in_array($property_name, $dont_set, true) |
|
126 | - && $this->attendee_model->has_field($property_name) |
|
127 | - ) { |
|
128 | - $existing_attendee->set($property_name, $property_value); |
|
129 | - } |
|
130 | - } |
|
131 | - // better save that now |
|
132 | - $existing_attendee->save(); |
|
133 | - return $existing_attendee; |
|
134 | - } |
|
108 | + /** |
|
109 | + * _update_existing_attendee_data |
|
110 | + * in case it has changed since last time they registered for an event |
|
111 | + * |
|
112 | + * @param EE_Attendee $existing_attendee |
|
113 | + * @param array $attendee_data |
|
114 | + * @return EE_Attendee |
|
115 | + * @throws EE_Error |
|
116 | + */ |
|
117 | + private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data) |
|
118 | + { |
|
119 | + // first remove fname, lname, and email from attendee data |
|
120 | + // because these properties will be exactly the same as the returned attendee object, |
|
121 | + // since they were used in the query to get the attendee object in the first place |
|
122 | + $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
123 | + // now loop thru what's left and add to attendee CPT |
|
124 | + foreach ($attendee_data as $property_name => $property_value) { |
|
125 | + if (! in_array($property_name, $dont_set, true) |
|
126 | + && $this->attendee_model->has_field($property_name) |
|
127 | + ) { |
|
128 | + $existing_attendee->set($property_name, $property_value); |
|
129 | + } |
|
130 | + } |
|
131 | + // better save that now |
|
132 | + $existing_attendee->save(); |
|
133 | + return $existing_attendee; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | |
137 | - /** |
|
138 | - * create_new_attendee |
|
139 | - * |
|
140 | - * @param EE_Registration $registration |
|
141 | - * @param array $attendee_data |
|
142 | - * @return EE_Attendee |
|
143 | - * @throws EE_Error |
|
144 | - */ |
|
145 | - private function createNewAttendee(EE_Registration $registration, array $attendee_data) |
|
146 | - { |
|
147 | - // create new attendee object |
|
148 | - $new_attendee = EE_Attendee::new_instance($attendee_data); |
|
149 | - // set author to event creator |
|
150 | - $new_attendee->set('ATT_author', $registration->event()->wp_user()); |
|
151 | - $new_attendee->save(); |
|
152 | - return $new_attendee; |
|
153 | - } |
|
137 | + /** |
|
138 | + * create_new_attendee |
|
139 | + * |
|
140 | + * @param EE_Registration $registration |
|
141 | + * @param array $attendee_data |
|
142 | + * @return EE_Attendee |
|
143 | + * @throws EE_Error |
|
144 | + */ |
|
145 | + private function createNewAttendee(EE_Registration $registration, array $attendee_data) |
|
146 | + { |
|
147 | + // create new attendee object |
|
148 | + $new_attendee = EE_Attendee::new_instance($attendee_data); |
|
149 | + // set author to event creator |
|
150 | + $new_attendee->set('ATT_author', $registration->event()->wp_user()); |
|
151 | + $new_attendee->save(); |
|
152 | + return $new_attendee; |
|
153 | + } |
|
154 | 154 | } |
@@ -122,7 +122,7 @@ |
||
122 | 122 | $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
123 | 123 | // now loop thru what's left and add to attendee CPT |
124 | 124 | foreach ($attendee_data as $property_name => $property_value) { |
125 | - if (! in_array($property_name, $dont_set, true) |
|
125 | + if ( ! in_array($property_name, $dont_set, true) |
|
126 | 126 | && $this->attendee_model->has_field($property_name) |
127 | 127 | ) { |
128 | 128 | $existing_attendee->set($property_name, $property_value); |