Completed
Branch BUG/update-unit-tests (7b5400)
by
unknown
07:51 queued 05:38
created
core/db_models/EEM_Datetime.model.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 ),
122 122
             ),
123 123
         );
124
-        $this->_model_relations        = array(
124
+        $this->_model_relations = array(
125 125
             'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
126 126
             'Event'   => new EE_Belongs_To_Relation(),
127 127
             'Checkin' => new EE_Has_Many_Relation(),
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
         $this->model_chain_to_password = $path_to_event_model;
132 132
         $this->_model_chain_to_wp_user = $path_to_event_model;
133 133
         // this model is generally available for reading
134
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public(
134
+        $this->_cap_restriction_generators[EEM_Base::caps_read]       = new EE_Restriction_Generator_Event_Related_Public(
135 135
             $path_to_event_model
136 136
         );
137
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected(
137
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected(
138 138
             $path_to_event_model
139 139
         );
140
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected(
140
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]       = new EE_Restriction_Generator_Event_Related_Protected(
141 141
             $path_to_event_model
142 142
         );
143
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
143
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]     = new EE_Restriction_Generator_Event_Related_Protected(
144 144
             $path_to_event_model,
145 145
             EEM_Base::caps_edit
146 146
         );
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
      */
247 247
     private function validateStartAndEndTimeForBlankDate($start_time, $end_time)
248 248
     {
249
-        if (! is_array($start_time)) {
249
+        if ( ! is_array($start_time)) {
250 250
             throw new InvalidDataTypeException('start_time', $start_time, 'array');
251 251
         }
252
-        if (! is_array($end_time)) {
252
+        if ( ! is_array($end_time)) {
253 253
             throw new InvalidDataTypeException('end_time', $end_time, 'array');
254 254
         }
255 255
         if (count($start_time) !== 2) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function get_all_event_dates($EVT_ID = 0)
285 285
     {
286
-        if (! $EVT_ID) { // on add_new_event event_id gets set to 0
286
+        if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
287 287
             return $this->create_new_blank_datetime();
288 288
         }
289 289
         $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 'order_by'                 => array('DTT_order' => 'ASC'),
330 330
                 'default_where_conditions' => 'none',
331 331
             );
332
-        if (! $include_expired) {
332
+        if ( ! $include_expired) {
333 333
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
334 334
         }
335 335
         if ($include_deleted) {
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             ),
449 449
             'default_where_conditions' => EEM_Base::default_where_conditions_this_only
450 450
         );
451
-        if (! $include_expired) {
451
+        if ( ! $include_expired) {
452 452
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
453 453
         }
454 454
         if ($include_deleted) {
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
         $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
487 487
         $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
488 488
         $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
489
-        if (! $include_expired) {
489
+        if ( ! $include_expired) {
490 490
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
491 491
         }
492 492
         if ($include_deleted) {
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
527 527
         $where_params = array('Ticket.TKT_ID' => $TKT_ID);
528 528
         $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
529
-        if (! $include_expired) {
529
+        if ( ! $include_expired) {
530 530
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
531 531
         }
532 532
         if ($include_deleted) {
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
             $this->get_timezone(),
650 650
             'DTT_EVT_start'
651 651
         );
652
-        $columns_to_select        = array(
653
-            'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
654
-            'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
655
-            'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
652
+        $columns_to_select = array(
653
+            'dtt_year'      => array('YEAR('.$query_interval.')', '%s'),
654
+            'dtt_month'     => array('MONTHNAME('.$query_interval.')', '%s'),
655
+            'dtt_month_num' => array('MONTH('.$query_interval.')', '%s'),
656 656
         );
657 657
         return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
658 658
     }
@@ -731,17 +731,17 @@  discard block
 block discarded – undo
731 731
                 array('DTT_EVT_end' => array('<', time()))
732 732
             ),
733 733
         );
734
-        if (! empty($stati_to_include)) {
734
+        if ( ! empty($stati_to_include)) {
735 735
             foreach (array_keys($status_query_args) as $status) {
736
-                if (! in_array($status, $stati_to_include, true)) {
737
-                    unset($status_query_args[ $status ]);
736
+                if ( ! in_array($status, $stati_to_include, true)) {
737
+                    unset($status_query_args[$status]);
738 738
                 }
739 739
             }
740 740
         }
741 741
         // loop through and query counts for each stati.
742 742
         $status_query_results = array();
743 743
         foreach ($status_query_args as $status => $status_where_conditions) {
744
-            $status_query_results[ $status ] = EEM_Datetime::count(
744
+            $status_query_results[$status] = EEM_Datetime::count(
745 745
                 array($status_where_conditions),
746 746
                 'DTT_ID',
747 747
                 true
@@ -762,6 +762,6 @@  discard block
 block discarded – undo
762 762
     public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
763 763
     {
764 764
         $count = $this->get_datetime_counts_by_status(array($status), $query_params);
765
-        return ! empty($count[ $status ]) ? $count[ $status ] : 0;
765
+        return ! empty($count[$status]) ? $count[$status] : 0;
766 766
     }
767 767
 }
Please login to merge, or discard this patch.
Indentation   +751 added lines, -751 removed lines patch added patch discarded remove patch
@@ -12,755 +12,755 @@
 block discarded – undo
12 12
  */
13 13
 class EEM_Datetime extends EEM_Soft_Delete_Base
14 14
 {
15
-    /**
16
-     * @var EEM_Datetime $_instance
17
-     */
18
-    protected static $_instance;
19
-
20
-
21
-    /**
22
-     * private constructor to prevent direct creation
23
-     *
24
-     * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings
25
-     *                         (and any incoming timezone data that gets saved).
26
-     *                         Note this just sends the timezone info to the date time model field objects.
27
-     *                         Default is NULL
28
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     * @throws InvalidArgumentException
32
-     */
33
-    protected function __construct($timezone)
34
-    {
35
-        $this->singular_item           = esc_html__('Datetime', 'event_espresso');
36
-        $this->plural_item             = esc_html__('Datetimes', 'event_espresso');
37
-        $this->_tables                 = array(
38
-            'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'),
39
-        );
40
-        $this->_fields                 = array(
41
-            'Datetime' => array(
42
-                'DTT_ID'          => new EE_Primary_Key_Int_Field(
43
-                    'DTT_ID',
44
-                    esc_html__('Datetime ID', 'event_espresso')
45
-                ),
46
-                'EVT_ID'          => new EE_Foreign_Key_Int_Field(
47
-                    'EVT_ID',
48
-                    esc_html__('Event ID', 'event_espresso'),
49
-                    false,
50
-                    0,
51
-                    'Event'
52
-                ),
53
-                'DTT_name'        => new EE_Plain_Text_Field(
54
-                    'DTT_name',
55
-                    esc_html__('Datetime Name', 'event_espresso'),
56
-                    false,
57
-                    ''
58
-                ),
59
-                'DTT_description' => new EE_Post_Content_Field(
60
-                    'DTT_description',
61
-                    esc_html__('Description for Datetime', 'event_espresso'),
62
-                    false,
63
-                    ''
64
-                ),
65
-                'DTT_EVT_start'   => new EE_Datetime_Field(
66
-                    'DTT_EVT_start',
67
-                    esc_html__('Start time/date of Event', 'event_espresso'),
68
-                    false,
69
-                    EE_Datetime_Field::now,
70
-                    $timezone
71
-                ),
72
-                'DTT_EVT_end'     => new EE_Datetime_Field(
73
-                    'DTT_EVT_end',
74
-                    esc_html__('End time/date of Event', 'event_espresso'),
75
-                    false,
76
-                    EE_Datetime_Field::now,
77
-                    $timezone
78
-                ),
79
-                'DTT_reg_limit'   => new EE_Infinite_Integer_Field(
80
-                    'DTT_reg_limit',
81
-                    esc_html__('Registration Limit for this time', 'event_espresso'),
82
-                    true,
83
-                    EE_INF
84
-                ),
85
-                'DTT_sold'        => new EE_Integer_Field(
86
-                    'DTT_sold',
87
-                    esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'),
88
-                    true,
89
-                    0
90
-                ),
91
-                'DTT_reserved'    => new EE_Integer_Field(
92
-                    'DTT_reserved',
93
-                    esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'),
94
-                    false,
95
-                    0
96
-                ),
97
-                'DTT_is_primary'  => new EE_Boolean_Field(
98
-                    'DTT_is_primary',
99
-                    esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'),
100
-                    false,
101
-                    false
102
-                ),
103
-                'DTT_order'       => new EE_Integer_Field(
104
-                    'DTT_order',
105
-                    esc_html__('The order in which the Datetime is displayed', 'event_espresso'),
106
-                    false,
107
-                    0
108
-                ),
109
-                'DTT_parent'      => new EE_Integer_Field(
110
-                    'DTT_parent',
111
-                    esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'),
112
-                    true,
113
-                    0
114
-                ),
115
-                'DTT_deleted'     => new EE_Trashed_Flag_Field(
116
-                    'DTT_deleted',
117
-                    esc_html__('Flag indicating datetime is archived', 'event_espresso'),
118
-                    false,
119
-                    false
120
-                ),
121
-            ),
122
-        );
123
-        $this->_model_relations        = array(
124
-            'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
125
-            'Event'   => new EE_Belongs_To_Relation(),
126
-            'Checkin' => new EE_Has_Many_Relation(),
127
-            'Datetime_Ticket' => new EE_Has_Many_Relation(),
128
-        );
129
-        $path_to_event_model = 'Event';
130
-        $this->model_chain_to_password = $path_to_event_model;
131
-        $this->_model_chain_to_wp_user = $path_to_event_model;
132
-        // this model is generally available for reading
133
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public(
134
-            $path_to_event_model
135
-        );
136
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected(
137
-            $path_to_event_model
138
-        );
139
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected(
140
-            $path_to_event_model
141
-        );
142
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
143
-            $path_to_event_model,
144
-            EEM_Base::caps_edit
145
-        );
146
-        parent::__construct($timezone);
147
-    }
148
-
149
-
150
-    /**
151
-     * create new blank datetime
152
-     *
153
-     * @access public
154
-     * @return EE_Datetime[] array on success, FALSE on fail
155
-     * @throws EE_Error
156
-     * @throws InvalidArgumentException
157
-     * @throws InvalidDataTypeException
158
-     * @throws ReflectionException
159
-     * @throws InvalidInterfaceException
160
-     */
161
-    public function create_new_blank_datetime()
162
-    {
163
-        // makes sure timezone is always set.
164
-        $timezone_string = $this->get_timezone();
165
-        /**
166
-         * Filters the initial start date for the new datetime.
167
-         * Any time included in this value will be overridden later so use additional filters to modify the time.
168
-         *
169
-         * @param int $start_date Unixtimestamp representing now + 30 days in seconds.
170
-         * @return int unixtimestamp
171
-         */
172
-        $start_date = apply_filters(
173
-            'FHEE__EEM_Datetime__create_new_blank_datetime__start_date',
174
-            $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS
175
-        );
176
-        /**
177
-         * Filters the initial end date for the new datetime.
178
-         * Any time included in this value will be overridden later so use additional filters to modify the time.
179
-         *
180
-         * @param int $end_data Unixtimestamp representing now + 30 days in seconds.
181
-         * @return int unixtimestamp
182
-         */
183
-        $end_date = apply_filters(
184
-            'FHEE__EEM_Datetime__create_new_blank_datetime__end_date',
185
-            $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS
186
-        );
187
-        $blank_datetime = EE_Datetime::new_instance(
188
-            array(
189
-                'DTT_EVT_start' => $start_date,
190
-                'DTT_EVT_end'   => $end_date,
191
-                'DTT_order'     => 1,
192
-                'DTT_reg_limit' => EE_INF,
193
-            ),
194
-            $timezone_string
195
-        );
196
-        /**
197
-         * Filters the initial start time and format for the new EE_Datetime instance.
198
-         *
199
-         * @param array $start_time An array having size 2.  First element is the time, second element is the time
200
-         *                          format.
201
-         * @return array
202
-         */
203
-        $start_time = apply_filters(
204
-            'FHEE__EEM_Datetime__create_new_blank_datetime__start_time',
205
-            ['8am', 'ga']
206
-        );
207
-        /**
208
-         * Filters the initial end time and format for the new EE_Datetime instance.
209
-         *
210
-         * @param array $end_time An array having size 2.  First element is the time, second element is the time
211
-         *                        format
212
-         * @return array
213
-         */
214
-        $end_time = apply_filters(
215
-            'FHEE__EEM_Datetime__create_new_blank_datetime__end_time',
216
-            ['5pm', 'ga']
217
-        );
218
-        $this->validateStartAndEndTimeForBlankDate($start_time, $end_time);
219
-        $blank_datetime->set_start_time(
220
-            $this->convert_datetime_for_query(
221
-                'DTT_EVT_start',
222
-                $start_time[0],
223
-                $start_time[1],
224
-                $timezone_string
225
-            )
226
-        );
227
-        $blank_datetime->set_end_time(
228
-            $this->convert_datetime_for_query(
229
-                'DTT_EVT_end',
230
-                $end_time[0],
231
-                $end_time[1],
232
-                $timezone_string
233
-            )
234
-        );
235
-        return array($blank_datetime);
236
-    }
237
-
238
-
239
-    /**
240
-     * Validates whether the start_time and end_time are in the expected format.
241
-     * @param array $start_time
242
-     * @param array $end_time
243
-     * @throws InvalidArgumentException
244
-     * @throws InvalidDataTypeException
245
-     */
246
-    private function validateStartAndEndTimeForBlankDate($start_time, $end_time)
247
-    {
248
-        if (! is_array($start_time)) {
249
-            throw new InvalidDataTypeException('start_time', $start_time, 'array');
250
-        }
251
-        if (! is_array($end_time)) {
252
-            throw new InvalidDataTypeException('end_time', $end_time, 'array');
253
-        }
254
-        if (count($start_time) !== 2) {
255
-            throw new InvalidArgumentException(
256
-                sprintf(
257
-                    'The variable %1$s is expected to be an array with two elements.  The first item in the '
258
-                    . 'array should be a valid time string, the second item in the array should be a valid time format',
259
-                    '$start_time'
260
-                )
261
-            );
262
-        }
263
-        if (count($end_time) !== 2) {
264
-            throw new InvalidArgumentException(
265
-                sprintf(
266
-                    'The variable %1$s is expected to be an array with two elements.  The first item in the '
267
-                    . 'array should be a valid time string, the second item in the array should be a valid time format',
268
-                    '$end_time'
269
-                )
270
-            );
271
-        }
272
-    }
273
-
274
-
275
-    /**
276
-     * get event start date from db
277
-     *
278
-     * @access public
279
-     * @param  int $EVT_ID
280
-     * @return EE_Datetime[] array on success, FALSE on fail
281
-     * @throws EE_Error
282
-     */
283
-    public function get_all_event_dates($EVT_ID = 0)
284
-    {
285
-        if (! $EVT_ID) { // on add_new_event event_id gets set to 0
286
-            return $this->create_new_blank_datetime();
287
-        }
288
-        $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
289
-        if (empty($results)) {
290
-            return $this->create_new_blank_datetime();
291
-        }
292
-        return $results;
293
-    }
294
-
295
-
296
-    /**
297
-     * get all datetimes attached to an event ordered by the DTT_order field
298
-     *
299
-     * @public
300
-     * @param  int    $EVT_ID     event id
301
-     * @param boolean $include_expired
302
-     * @param boolean $include_deleted
303
-     * @param  int    $limit      If included then limit the count of results by
304
-     *                            the given number
305
-     * @return EE_Datetime[]
306
-     * @throws EE_Error
307
-     */
308
-    public function get_datetimes_for_event_ordered_by_DTT_order(
309
-        $EVT_ID,
310
-        $include_expired = true,
311
-        $include_deleted = true,
312
-        $limit = null
313
-    ) {
314
-        // sanitize EVT_ID
315
-        $EVT_ID         = absint($EVT_ID);
316
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
317
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
318
-        $where_params = array('Event.EVT_ID' => $EVT_ID);
319
-        $query_params = ! empty($limit)
320
-            ? array(
321
-                $where_params,
322
-                'limit'                    => $limit,
323
-                'order_by'                 => array('DTT_order' => 'ASC'),
324
-                'default_where_conditions' => 'none',
325
-            )
326
-            : array(
327
-                $where_params,
328
-                'order_by'                 => array('DTT_order' => 'ASC'),
329
-                'default_where_conditions' => 'none',
330
-            );
331
-        if (! $include_expired) {
332
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
333
-        }
334
-        if ($include_deleted) {
335
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
336
-        }
337
-        /** @var EE_Datetime[] $result */
338
-        $result = $this->get_all($query_params);
339
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
340
-        return $result;
341
-    }
342
-
343
-
344
-    /**
345
-     * Gets the datetimes for the event (with the given limit), and orders them by "importance".
346
-     * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW),
347
-     * and then the earlier datetimes are the most important.
348
-     * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet.
349
-     *
350
-     * @param int $EVT_ID
351
-     * @param int $limit
352
-     * @return EE_Datetime[]|EE_Base_Class[]
353
-     * @throws EE_Error
354
-     */
355
-    public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null)
356
-    {
357
-        return $this->get_all(
358
-            array(
359
-                array('Event.EVT_ID' => $EVT_ID),
360
-                'limit'                    => $limit,
361
-                'order_by'                 => array('DTT_EVT_start' => 'ASC'),
362
-                'default_where_conditions' => 'none',
363
-            )
364
-        );
365
-    }
366
-
367
-
368
-    /**
369
-     * @param int     $EVT_ID
370
-     * @param boolean $include_expired
371
-     * @param boolean $include_deleted
372
-     * @return EE_Datetime
373
-     * @throws EE_Error
374
-     */
375
-    public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false)
376
-    {
377
-        $results = $this->get_datetimes_for_event_ordered_by_start_time(
378
-            $EVT_ID,
379
-            $include_expired,
380
-            $include_deleted,
381
-            1
382
-        );
383
-        if ($results) {
384
-            return array_shift($results);
385
-        }
386
-        return null;
387
-    }
388
-
389
-
390
-    /**
391
-     * Gets the 'primary' datetime for an event.
392
-     *
393
-     * @param int  $EVT_ID
394
-     * @param bool $try_to_exclude_expired
395
-     * @param bool $try_to_exclude_deleted
396
-     * @return \EE_Datetime
397
-     * @throws EE_Error
398
-     */
399
-    public function get_primary_datetime_for_event(
400
-        $EVT_ID,
401
-        $try_to_exclude_expired = true,
402
-        $try_to_exclude_deleted = true
403
-    ) {
404
-        if ($try_to_exclude_expired) {
405
-            $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
406
-            if ($non_expired) {
407
-                return $non_expired;
408
-            }
409
-        }
410
-        if ($try_to_exclude_deleted) {
411
-            $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
412
-            if ($expired_even) {
413
-                return $expired_even;
414
-            }
415
-        }
416
-        return $this->get_oldest_datetime_for_event($EVT_ID, true, true);
417
-    }
418
-
419
-
420
-    /**
421
-     * Gets ALL the datetimes for an event (including trashed ones, for now), ordered
422
-     * only by start date
423
-     *
424
-     * @param int     $EVT_ID
425
-     * @param boolean $include_expired
426
-     * @param boolean $include_deleted
427
-     * @param int     $limit
428
-     * @return EE_Datetime[]
429
-     * @throws EE_Error
430
-     */
431
-    public function get_datetimes_for_event_ordered_by_start_time(
432
-        $EVT_ID,
433
-        $include_expired = true,
434
-        $include_deleted = true,
435
-        $limit = null
436
-    ) {
437
-        // sanitize EVT_ID
438
-        $EVT_ID         = absint($EVT_ID);
439
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
440
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
441
-        $query_params = array(
442
-            array(
443
-                'Event.EVT_ID' => $EVT_ID
444
-            ),
445
-            'order_by' => array(
446
-                'DTT_EVT_start' => 'asc'
447
-            ),
448
-            'default_where_conditions' => EEM_Base::default_where_conditions_this_only
449
-        );
450
-        if (! $include_expired) {
451
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
452
-        }
453
-        if ($include_deleted) {
454
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
455
-        }
456
-        if ($limit) {
457
-            $query_params['limit'] = $limit;
458
-        }
459
-        /** @var EE_Datetime[] $result */
460
-        $result = $this->get_all($query_params);
461
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
462
-        return $result;
463
-    }
464
-
465
-
466
-    /**
467
-     * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
468
-     * only by start date
469
-     *
470
-     * @param int     $TKT_ID
471
-     * @param boolean $include_expired
472
-     * @param boolean $include_deleted
473
-     * @param int     $limit
474
-     * @return EE_Datetime[]
475
-     * @throws EE_Error
476
-     */
477
-    public function get_datetimes_for_ticket_ordered_by_start_time(
478
-        $TKT_ID,
479
-        $include_expired = true,
480
-        $include_deleted = true,
481
-        $limit = null
482
-    ) {
483
-        // sanitize TKT_ID
484
-        $TKT_ID         = absint($TKT_ID);
485
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
486
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
487
-        $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
488
-        if (! $include_expired) {
489
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
490
-        }
491
-        if ($include_deleted) {
492
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
493
-        }
494
-        if ($limit) {
495
-            $query_params['limit'] = $limit;
496
-        }
497
-        /** @var EE_Datetime[] $result */
498
-        $result = $this->get_all($query_params);
499
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
500
-        return $result;
501
-    }
502
-
503
-
504
-    /**
505
-     * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the
506
-     * datetimes.
507
-     *
508
-     * @param  int      $TKT_ID          ID of ticket to retrieve the datetimes for
509
-     * @param  boolean  $include_expired whether to include expired datetimes or not
510
-     * @param  boolean  $include_deleted whether to include trashed datetimes or not.
511
-     * @param  int|null $limit           if null, no limit, if int then limit results by
512
-     *                                   that number
513
-     * @return EE_Datetime[]
514
-     * @throws EE_Error
515
-     */
516
-    public function get_datetimes_for_ticket_ordered_by_DTT_order(
517
-        $TKT_ID,
518
-        $include_expired = true,
519
-        $include_deleted = true,
520
-        $limit = null
521
-    ) {
522
-        // sanitize id.
523
-        $TKT_ID         = absint($TKT_ID);
524
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
525
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
526
-        $where_params = array('Ticket.TKT_ID' => $TKT_ID);
527
-        $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
528
-        if (! $include_expired) {
529
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
530
-        }
531
-        if ($include_deleted) {
532
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
533
-        }
534
-        if ($limit) {
535
-            $query_params['limit'] = $limit;
536
-        }
537
-        /** @var EE_Datetime[] $result */
538
-        $result = $this->get_all($query_params);
539
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
540
-        return $result;
541
-    }
542
-
543
-
544
-    /**
545
-     * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK
546
-     * reason it doesn't exist, we consider the earliest event the most important)
547
-     *
548
-     * @param int $EVT_ID
549
-     * @return EE_Datetime
550
-     * @throws EE_Error
551
-     */
552
-    public function get_most_important_datetime_for_event($EVT_ID)
553
-    {
554
-        $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
555
-        if ($results) {
556
-            return array_shift($results);
557
-        }
558
-        return null;
559
-    }
560
-
561
-
562
-    /**
563
-     * This returns a wpdb->results        Array of all DTT month and years matching the incoming query params and
564
-     * grouped by month and year.
565
-     *
566
-     * @param  array  $where_params      @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
567
-     * @param  string $evt_active_status A string representing the evt active status to filter the months by.
568
-     *                                   Can be:
569
-     *                                   - '' = no filter
570
-     *                                   - upcoming = Published events with at least one upcoming datetime.
571
-     *                                   - expired = Events with all datetimes expired.
572
-     *                                   - active = Events that are published and have at least one datetime that
573
-     *                                   starts before now and ends after now.
574
-     *                                   - inactive = Events that are either not published.
575
-     * @return stdClass[]
576
-     * @throws EE_Error
577
-     * @throws InvalidArgumentException
578
-     * @throws InvalidArgumentException
579
-     */
580
-    public function get_dtt_months_and_years($where_params, $evt_active_status = '')
581
-    {
582
-        $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
583
-        $current_time_for_DTT_EVT_end   = $this->current_time_for_query('DTT_EVT_end');
584
-        switch ($evt_active_status) {
585
-            case 'upcoming':
586
-                $where_params['Event.status'] = 'publish';
587
-                // if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
588
-                if (isset($where_params['DTT_EVT_start'])) {
589
-                    $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
590
-                }
591
-                $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
592
-                break;
593
-            case 'expired':
594
-                if (isset($where_params['Event.status'])) {
595
-                    unset($where_params['Event.status']);
596
-                }
597
-                // get events to exclude
598
-                $exclude_query[0] = array_merge(
599
-                    $where_params,
600
-                    array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))
601
-                );
602
-                // first get all events that have datetimes where its not expired.
603
-                $event_ids = $this->_get_all_wpdb_results(
604
-                    $exclude_query,
605
-                    OBJECT_K,
606
-                    'Datetime.EVT_ID'
607
-                );
608
-                $event_ids = array_keys($event_ids);
609
-                if (isset($where_params['DTT_EVT_end'])) {
610
-                    $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
611
-                }
612
-                $where_params['DTT_EVT_end']  = array('<', $current_time_for_DTT_EVT_end);
613
-                $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
614
-                break;
615
-            case 'active':
616
-                $where_params['Event.status'] = 'publish';
617
-                if (isset($where_params['DTT_EVT_start'])) {
618
-                    $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
619
-                }
620
-                if (isset($where_params['Datetime.DTT_EVT_end'])) {
621
-                    $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
622
-                }
623
-                $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
624
-                $where_params['DTT_EVT_end']   = array('>', $current_time_for_DTT_EVT_end);
625
-                break;
626
-            case 'inactive':
627
-                if (isset($where_params['Event.status'])) {
628
-                    unset($where_params['Event.status']);
629
-                }
630
-                if (isset($where_params['OR'])) {
631
-                    $where_params['AND']['OR'] = $where_params['OR'];
632
-                }
633
-                if (isset($where_params['DTT_EVT_end'])) {
634
-                    $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
635
-                    unset($where_params['DTT_EVT_end']);
636
-                }
637
-                if (isset($where_params['DTT_EVT_start'])) {
638
-                    $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
639
-                    unset($where_params['DTT_EVT_start']);
640
-                }
641
-                $where_params['AND']['Event.status'] = array('!=', 'publish');
642
-                break;
643
-        }
644
-        $query_params[0]          = $where_params;
645
-        $query_params['group_by'] = array('dtt_year', 'dtt_month');
646
-        $query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
647
-        $query_interval           = EEH_DTT_Helper::get_sql_query_interval_for_offset(
648
-            $this->get_timezone(),
649
-            'DTT_EVT_start'
650
-        );
651
-        $columns_to_select        = array(
652
-            'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
653
-            'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
654
-            'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
655
-        );
656
-        return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
657
-    }
658
-
659
-
660
-    /**
661
-     * Updates the DTT_sold attribute on each datetime (based on the registrations
662
-     * for the tickets for each datetime)
663
-     *
664
-     * @param EE_Base_Class[]|EE_Datetime[] $datetimes
665
-     * @throws EE_Error
666
-     */
667
-    public function update_sold($datetimes)
668
-    {
669
-        EE_Error::doing_it_wrong(
670
-            __FUNCTION__,
671
-            esc_html__(
672
-                'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.',
673
-                'event_espresso'
674
-            ),
675
-            '4.9.32.rc.005'
676
-        );
677
-        foreach ($datetimes as $datetime) {
678
-            $datetime->update_sold();
679
-        }
680
-    }
681
-
682
-
683
-    /**
684
-     *    Gets the total number of tickets available at a particular datetime
685
-     *    (does NOT take into account the datetime's spaces available)
686
-     *
687
-     * @param int   $DTT_ID
688
-     * @param array $query_params
689
-     * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO
690
-     *             tickets attached to datetime then FALSE is returned.
691
-     */
692
-    public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array())
693
-    {
694
-        $datetime = $this->get_one_by_ID($DTT_ID);
695
-        if ($datetime instanceof EE_Datetime) {
696
-            return $datetime->tickets_remaining($query_params);
697
-        }
698
-        return 0;
699
-    }
700
-
701
-
702
-    /**
703
-     * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
704
-     *
705
-     * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
706
-     *                                 stati you want counts for as values in the array.  An empty array returns counts
707
-     *                                 for all valid stati.
708
-     * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
709
-     *                                 only for Datetimes connected to a specific event, or specific ticket.
710
-     * @return array  The value returned is an array indexed by Datetime Status and the values are the counts.  The
711
-     * @throws EE_Error
712
-     *                                 stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming
713
-     *                                 EE_Datetime::expired
714
-     */
715
-    public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array())
716
-    {
717
-        // only accept where conditions for this query.
718
-        $_where            = isset($query_params[0]) ? $query_params[0] : array();
719
-        $status_query_args = array(
720
-            EE_Datetime::active   => array_merge(
721
-                $_where,
722
-                array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
723
-            ),
724
-            EE_Datetime::upcoming => array_merge(
725
-                $_where,
726
-                array('DTT_EVT_start' => array('>', time()))
727
-            ),
728
-            EE_Datetime::expired  => array_merge(
729
-                $_where,
730
-                array('DTT_EVT_end' => array('<', time()))
731
-            ),
732
-        );
733
-        if (! empty($stati_to_include)) {
734
-            foreach (array_keys($status_query_args) as $status) {
735
-                if (! in_array($status, $stati_to_include, true)) {
736
-                    unset($status_query_args[ $status ]);
737
-                }
738
-            }
739
-        }
740
-        // loop through and query counts for each stati.
741
-        $status_query_results = array();
742
-        foreach ($status_query_args as $status => $status_where_conditions) {
743
-            $status_query_results[ $status ] = EEM_Datetime::count(
744
-                array($status_where_conditions),
745
-                'DTT_ID',
746
-                true
747
-            );
748
-        }
749
-        return $status_query_results;
750
-    }
751
-
752
-
753
-    /**
754
-     * Returns the specific count for a given Datetime status matching any given query_params.
755
-     *
756
-     * @param string $status Valid string representation for Datetime status requested. (Defaults to Active).
757
-     * @param array  $query_params
758
-     * @return int
759
-     * @throws EE_Error
760
-     */
761
-    public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
762
-    {
763
-        $count = $this->get_datetime_counts_by_status(array($status), $query_params);
764
-        return ! empty($count[ $status ]) ? $count[ $status ] : 0;
765
-    }
15
+	/**
16
+	 * @var EEM_Datetime $_instance
17
+	 */
18
+	protected static $_instance;
19
+
20
+
21
+	/**
22
+	 * private constructor to prevent direct creation
23
+	 *
24
+	 * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings
25
+	 *                         (and any incoming timezone data that gets saved).
26
+	 *                         Note this just sends the timezone info to the date time model field objects.
27
+	 *                         Default is NULL
28
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 * @throws InvalidArgumentException
32
+	 */
33
+	protected function __construct($timezone)
34
+	{
35
+		$this->singular_item           = esc_html__('Datetime', 'event_espresso');
36
+		$this->plural_item             = esc_html__('Datetimes', 'event_espresso');
37
+		$this->_tables                 = array(
38
+			'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'),
39
+		);
40
+		$this->_fields                 = array(
41
+			'Datetime' => array(
42
+				'DTT_ID'          => new EE_Primary_Key_Int_Field(
43
+					'DTT_ID',
44
+					esc_html__('Datetime ID', 'event_espresso')
45
+				),
46
+				'EVT_ID'          => new EE_Foreign_Key_Int_Field(
47
+					'EVT_ID',
48
+					esc_html__('Event ID', 'event_espresso'),
49
+					false,
50
+					0,
51
+					'Event'
52
+				),
53
+				'DTT_name'        => new EE_Plain_Text_Field(
54
+					'DTT_name',
55
+					esc_html__('Datetime Name', 'event_espresso'),
56
+					false,
57
+					''
58
+				),
59
+				'DTT_description' => new EE_Post_Content_Field(
60
+					'DTT_description',
61
+					esc_html__('Description for Datetime', 'event_espresso'),
62
+					false,
63
+					''
64
+				),
65
+				'DTT_EVT_start'   => new EE_Datetime_Field(
66
+					'DTT_EVT_start',
67
+					esc_html__('Start time/date of Event', 'event_espresso'),
68
+					false,
69
+					EE_Datetime_Field::now,
70
+					$timezone
71
+				),
72
+				'DTT_EVT_end'     => new EE_Datetime_Field(
73
+					'DTT_EVT_end',
74
+					esc_html__('End time/date of Event', 'event_espresso'),
75
+					false,
76
+					EE_Datetime_Field::now,
77
+					$timezone
78
+				),
79
+				'DTT_reg_limit'   => new EE_Infinite_Integer_Field(
80
+					'DTT_reg_limit',
81
+					esc_html__('Registration Limit for this time', 'event_espresso'),
82
+					true,
83
+					EE_INF
84
+				),
85
+				'DTT_sold'        => new EE_Integer_Field(
86
+					'DTT_sold',
87
+					esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'),
88
+					true,
89
+					0
90
+				),
91
+				'DTT_reserved'    => new EE_Integer_Field(
92
+					'DTT_reserved',
93
+					esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'),
94
+					false,
95
+					0
96
+				),
97
+				'DTT_is_primary'  => new EE_Boolean_Field(
98
+					'DTT_is_primary',
99
+					esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'),
100
+					false,
101
+					false
102
+				),
103
+				'DTT_order'       => new EE_Integer_Field(
104
+					'DTT_order',
105
+					esc_html__('The order in which the Datetime is displayed', 'event_espresso'),
106
+					false,
107
+					0
108
+				),
109
+				'DTT_parent'      => new EE_Integer_Field(
110
+					'DTT_parent',
111
+					esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'),
112
+					true,
113
+					0
114
+				),
115
+				'DTT_deleted'     => new EE_Trashed_Flag_Field(
116
+					'DTT_deleted',
117
+					esc_html__('Flag indicating datetime is archived', 'event_espresso'),
118
+					false,
119
+					false
120
+				),
121
+			),
122
+		);
123
+		$this->_model_relations        = array(
124
+			'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
125
+			'Event'   => new EE_Belongs_To_Relation(),
126
+			'Checkin' => new EE_Has_Many_Relation(),
127
+			'Datetime_Ticket' => new EE_Has_Many_Relation(),
128
+		);
129
+		$path_to_event_model = 'Event';
130
+		$this->model_chain_to_password = $path_to_event_model;
131
+		$this->_model_chain_to_wp_user = $path_to_event_model;
132
+		// this model is generally available for reading
133
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public(
134
+			$path_to_event_model
135
+		);
136
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected(
137
+			$path_to_event_model
138
+		);
139
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected(
140
+			$path_to_event_model
141
+		);
142
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
143
+			$path_to_event_model,
144
+			EEM_Base::caps_edit
145
+		);
146
+		parent::__construct($timezone);
147
+	}
148
+
149
+
150
+	/**
151
+	 * create new blank datetime
152
+	 *
153
+	 * @access public
154
+	 * @return EE_Datetime[] array on success, FALSE on fail
155
+	 * @throws EE_Error
156
+	 * @throws InvalidArgumentException
157
+	 * @throws InvalidDataTypeException
158
+	 * @throws ReflectionException
159
+	 * @throws InvalidInterfaceException
160
+	 */
161
+	public function create_new_blank_datetime()
162
+	{
163
+		// makes sure timezone is always set.
164
+		$timezone_string = $this->get_timezone();
165
+		/**
166
+		 * Filters the initial start date for the new datetime.
167
+		 * Any time included in this value will be overridden later so use additional filters to modify the time.
168
+		 *
169
+		 * @param int $start_date Unixtimestamp representing now + 30 days in seconds.
170
+		 * @return int unixtimestamp
171
+		 */
172
+		$start_date = apply_filters(
173
+			'FHEE__EEM_Datetime__create_new_blank_datetime__start_date',
174
+			$this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS
175
+		);
176
+		/**
177
+		 * Filters the initial end date for the new datetime.
178
+		 * Any time included in this value will be overridden later so use additional filters to modify the time.
179
+		 *
180
+		 * @param int $end_data Unixtimestamp representing now + 30 days in seconds.
181
+		 * @return int unixtimestamp
182
+		 */
183
+		$end_date = apply_filters(
184
+			'FHEE__EEM_Datetime__create_new_blank_datetime__end_date',
185
+			$this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS
186
+		);
187
+		$blank_datetime = EE_Datetime::new_instance(
188
+			array(
189
+				'DTT_EVT_start' => $start_date,
190
+				'DTT_EVT_end'   => $end_date,
191
+				'DTT_order'     => 1,
192
+				'DTT_reg_limit' => EE_INF,
193
+			),
194
+			$timezone_string
195
+		);
196
+		/**
197
+		 * Filters the initial start time and format for the new EE_Datetime instance.
198
+		 *
199
+		 * @param array $start_time An array having size 2.  First element is the time, second element is the time
200
+		 *                          format.
201
+		 * @return array
202
+		 */
203
+		$start_time = apply_filters(
204
+			'FHEE__EEM_Datetime__create_new_blank_datetime__start_time',
205
+			['8am', 'ga']
206
+		);
207
+		/**
208
+		 * Filters the initial end time and format for the new EE_Datetime instance.
209
+		 *
210
+		 * @param array $end_time An array having size 2.  First element is the time, second element is the time
211
+		 *                        format
212
+		 * @return array
213
+		 */
214
+		$end_time = apply_filters(
215
+			'FHEE__EEM_Datetime__create_new_blank_datetime__end_time',
216
+			['5pm', 'ga']
217
+		);
218
+		$this->validateStartAndEndTimeForBlankDate($start_time, $end_time);
219
+		$blank_datetime->set_start_time(
220
+			$this->convert_datetime_for_query(
221
+				'DTT_EVT_start',
222
+				$start_time[0],
223
+				$start_time[1],
224
+				$timezone_string
225
+			)
226
+		);
227
+		$blank_datetime->set_end_time(
228
+			$this->convert_datetime_for_query(
229
+				'DTT_EVT_end',
230
+				$end_time[0],
231
+				$end_time[1],
232
+				$timezone_string
233
+			)
234
+		);
235
+		return array($blank_datetime);
236
+	}
237
+
238
+
239
+	/**
240
+	 * Validates whether the start_time and end_time are in the expected format.
241
+	 * @param array $start_time
242
+	 * @param array $end_time
243
+	 * @throws InvalidArgumentException
244
+	 * @throws InvalidDataTypeException
245
+	 */
246
+	private function validateStartAndEndTimeForBlankDate($start_time, $end_time)
247
+	{
248
+		if (! is_array($start_time)) {
249
+			throw new InvalidDataTypeException('start_time', $start_time, 'array');
250
+		}
251
+		if (! is_array($end_time)) {
252
+			throw new InvalidDataTypeException('end_time', $end_time, 'array');
253
+		}
254
+		if (count($start_time) !== 2) {
255
+			throw new InvalidArgumentException(
256
+				sprintf(
257
+					'The variable %1$s is expected to be an array with two elements.  The first item in the '
258
+					. 'array should be a valid time string, the second item in the array should be a valid time format',
259
+					'$start_time'
260
+				)
261
+			);
262
+		}
263
+		if (count($end_time) !== 2) {
264
+			throw new InvalidArgumentException(
265
+				sprintf(
266
+					'The variable %1$s is expected to be an array with two elements.  The first item in the '
267
+					. 'array should be a valid time string, the second item in the array should be a valid time format',
268
+					'$end_time'
269
+				)
270
+			);
271
+		}
272
+	}
273
+
274
+
275
+	/**
276
+	 * get event start date from db
277
+	 *
278
+	 * @access public
279
+	 * @param  int $EVT_ID
280
+	 * @return EE_Datetime[] array on success, FALSE on fail
281
+	 * @throws EE_Error
282
+	 */
283
+	public function get_all_event_dates($EVT_ID = 0)
284
+	{
285
+		if (! $EVT_ID) { // on add_new_event event_id gets set to 0
286
+			return $this->create_new_blank_datetime();
287
+		}
288
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
289
+		if (empty($results)) {
290
+			return $this->create_new_blank_datetime();
291
+		}
292
+		return $results;
293
+	}
294
+
295
+
296
+	/**
297
+	 * get all datetimes attached to an event ordered by the DTT_order field
298
+	 *
299
+	 * @public
300
+	 * @param  int    $EVT_ID     event id
301
+	 * @param boolean $include_expired
302
+	 * @param boolean $include_deleted
303
+	 * @param  int    $limit      If included then limit the count of results by
304
+	 *                            the given number
305
+	 * @return EE_Datetime[]
306
+	 * @throws EE_Error
307
+	 */
308
+	public function get_datetimes_for_event_ordered_by_DTT_order(
309
+		$EVT_ID,
310
+		$include_expired = true,
311
+		$include_deleted = true,
312
+		$limit = null
313
+	) {
314
+		// sanitize EVT_ID
315
+		$EVT_ID         = absint($EVT_ID);
316
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
317
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
318
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
319
+		$query_params = ! empty($limit)
320
+			? array(
321
+				$where_params,
322
+				'limit'                    => $limit,
323
+				'order_by'                 => array('DTT_order' => 'ASC'),
324
+				'default_where_conditions' => 'none',
325
+			)
326
+			: array(
327
+				$where_params,
328
+				'order_by'                 => array('DTT_order' => 'ASC'),
329
+				'default_where_conditions' => 'none',
330
+			);
331
+		if (! $include_expired) {
332
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
333
+		}
334
+		if ($include_deleted) {
335
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
336
+		}
337
+		/** @var EE_Datetime[] $result */
338
+		$result = $this->get_all($query_params);
339
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
340
+		return $result;
341
+	}
342
+
343
+
344
+	/**
345
+	 * Gets the datetimes for the event (with the given limit), and orders them by "importance".
346
+	 * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW),
347
+	 * and then the earlier datetimes are the most important.
348
+	 * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet.
349
+	 *
350
+	 * @param int $EVT_ID
351
+	 * @param int $limit
352
+	 * @return EE_Datetime[]|EE_Base_Class[]
353
+	 * @throws EE_Error
354
+	 */
355
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null)
356
+	{
357
+		return $this->get_all(
358
+			array(
359
+				array('Event.EVT_ID' => $EVT_ID),
360
+				'limit'                    => $limit,
361
+				'order_by'                 => array('DTT_EVT_start' => 'ASC'),
362
+				'default_where_conditions' => 'none',
363
+			)
364
+		);
365
+	}
366
+
367
+
368
+	/**
369
+	 * @param int     $EVT_ID
370
+	 * @param boolean $include_expired
371
+	 * @param boolean $include_deleted
372
+	 * @return EE_Datetime
373
+	 * @throws EE_Error
374
+	 */
375
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false)
376
+	{
377
+		$results = $this->get_datetimes_for_event_ordered_by_start_time(
378
+			$EVT_ID,
379
+			$include_expired,
380
+			$include_deleted,
381
+			1
382
+		);
383
+		if ($results) {
384
+			return array_shift($results);
385
+		}
386
+		return null;
387
+	}
388
+
389
+
390
+	/**
391
+	 * Gets the 'primary' datetime for an event.
392
+	 *
393
+	 * @param int  $EVT_ID
394
+	 * @param bool $try_to_exclude_expired
395
+	 * @param bool $try_to_exclude_deleted
396
+	 * @return \EE_Datetime
397
+	 * @throws EE_Error
398
+	 */
399
+	public function get_primary_datetime_for_event(
400
+		$EVT_ID,
401
+		$try_to_exclude_expired = true,
402
+		$try_to_exclude_deleted = true
403
+	) {
404
+		if ($try_to_exclude_expired) {
405
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
406
+			if ($non_expired) {
407
+				return $non_expired;
408
+			}
409
+		}
410
+		if ($try_to_exclude_deleted) {
411
+			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
412
+			if ($expired_even) {
413
+				return $expired_even;
414
+			}
415
+		}
416
+		return $this->get_oldest_datetime_for_event($EVT_ID, true, true);
417
+	}
418
+
419
+
420
+	/**
421
+	 * Gets ALL the datetimes for an event (including trashed ones, for now), ordered
422
+	 * only by start date
423
+	 *
424
+	 * @param int     $EVT_ID
425
+	 * @param boolean $include_expired
426
+	 * @param boolean $include_deleted
427
+	 * @param int     $limit
428
+	 * @return EE_Datetime[]
429
+	 * @throws EE_Error
430
+	 */
431
+	public function get_datetimes_for_event_ordered_by_start_time(
432
+		$EVT_ID,
433
+		$include_expired = true,
434
+		$include_deleted = true,
435
+		$limit = null
436
+	) {
437
+		// sanitize EVT_ID
438
+		$EVT_ID         = absint($EVT_ID);
439
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
440
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
441
+		$query_params = array(
442
+			array(
443
+				'Event.EVT_ID' => $EVT_ID
444
+			),
445
+			'order_by' => array(
446
+				'DTT_EVT_start' => 'asc'
447
+			),
448
+			'default_where_conditions' => EEM_Base::default_where_conditions_this_only
449
+		);
450
+		if (! $include_expired) {
451
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
452
+		}
453
+		if ($include_deleted) {
454
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
455
+		}
456
+		if ($limit) {
457
+			$query_params['limit'] = $limit;
458
+		}
459
+		/** @var EE_Datetime[] $result */
460
+		$result = $this->get_all($query_params);
461
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
462
+		return $result;
463
+	}
464
+
465
+
466
+	/**
467
+	 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
468
+	 * only by start date
469
+	 *
470
+	 * @param int     $TKT_ID
471
+	 * @param boolean $include_expired
472
+	 * @param boolean $include_deleted
473
+	 * @param int     $limit
474
+	 * @return EE_Datetime[]
475
+	 * @throws EE_Error
476
+	 */
477
+	public function get_datetimes_for_ticket_ordered_by_start_time(
478
+		$TKT_ID,
479
+		$include_expired = true,
480
+		$include_deleted = true,
481
+		$limit = null
482
+	) {
483
+		// sanitize TKT_ID
484
+		$TKT_ID         = absint($TKT_ID);
485
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
486
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
487
+		$query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
488
+		if (! $include_expired) {
489
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
490
+		}
491
+		if ($include_deleted) {
492
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
493
+		}
494
+		if ($limit) {
495
+			$query_params['limit'] = $limit;
496
+		}
497
+		/** @var EE_Datetime[] $result */
498
+		$result = $this->get_all($query_params);
499
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
500
+		return $result;
501
+	}
502
+
503
+
504
+	/**
505
+	 * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the
506
+	 * datetimes.
507
+	 *
508
+	 * @param  int      $TKT_ID          ID of ticket to retrieve the datetimes for
509
+	 * @param  boolean  $include_expired whether to include expired datetimes or not
510
+	 * @param  boolean  $include_deleted whether to include trashed datetimes or not.
511
+	 * @param  int|null $limit           if null, no limit, if int then limit results by
512
+	 *                                   that number
513
+	 * @return EE_Datetime[]
514
+	 * @throws EE_Error
515
+	 */
516
+	public function get_datetimes_for_ticket_ordered_by_DTT_order(
517
+		$TKT_ID,
518
+		$include_expired = true,
519
+		$include_deleted = true,
520
+		$limit = null
521
+	) {
522
+		// sanitize id.
523
+		$TKT_ID         = absint($TKT_ID);
524
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
525
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
526
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
527
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
528
+		if (! $include_expired) {
529
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
530
+		}
531
+		if ($include_deleted) {
532
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
533
+		}
534
+		if ($limit) {
535
+			$query_params['limit'] = $limit;
536
+		}
537
+		/** @var EE_Datetime[] $result */
538
+		$result = $this->get_all($query_params);
539
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
540
+		return $result;
541
+	}
542
+
543
+
544
+	/**
545
+	 * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK
546
+	 * reason it doesn't exist, we consider the earliest event the most important)
547
+	 *
548
+	 * @param int $EVT_ID
549
+	 * @return EE_Datetime
550
+	 * @throws EE_Error
551
+	 */
552
+	public function get_most_important_datetime_for_event($EVT_ID)
553
+	{
554
+		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
555
+		if ($results) {
556
+			return array_shift($results);
557
+		}
558
+		return null;
559
+	}
560
+
561
+
562
+	/**
563
+	 * This returns a wpdb->results        Array of all DTT month and years matching the incoming query params and
564
+	 * grouped by month and year.
565
+	 *
566
+	 * @param  array  $where_params      @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
567
+	 * @param  string $evt_active_status A string representing the evt active status to filter the months by.
568
+	 *                                   Can be:
569
+	 *                                   - '' = no filter
570
+	 *                                   - upcoming = Published events with at least one upcoming datetime.
571
+	 *                                   - expired = Events with all datetimes expired.
572
+	 *                                   - active = Events that are published and have at least one datetime that
573
+	 *                                   starts before now and ends after now.
574
+	 *                                   - inactive = Events that are either not published.
575
+	 * @return stdClass[]
576
+	 * @throws EE_Error
577
+	 * @throws InvalidArgumentException
578
+	 * @throws InvalidArgumentException
579
+	 */
580
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '')
581
+	{
582
+		$current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
583
+		$current_time_for_DTT_EVT_end   = $this->current_time_for_query('DTT_EVT_end');
584
+		switch ($evt_active_status) {
585
+			case 'upcoming':
586
+				$where_params['Event.status'] = 'publish';
587
+				// if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
588
+				if (isset($where_params['DTT_EVT_start'])) {
589
+					$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
590
+				}
591
+				$where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
592
+				break;
593
+			case 'expired':
594
+				if (isset($where_params['Event.status'])) {
595
+					unset($where_params['Event.status']);
596
+				}
597
+				// get events to exclude
598
+				$exclude_query[0] = array_merge(
599
+					$where_params,
600
+					array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))
601
+				);
602
+				// first get all events that have datetimes where its not expired.
603
+				$event_ids = $this->_get_all_wpdb_results(
604
+					$exclude_query,
605
+					OBJECT_K,
606
+					'Datetime.EVT_ID'
607
+				);
608
+				$event_ids = array_keys($event_ids);
609
+				if (isset($where_params['DTT_EVT_end'])) {
610
+					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
611
+				}
612
+				$where_params['DTT_EVT_end']  = array('<', $current_time_for_DTT_EVT_end);
613
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
614
+				break;
615
+			case 'active':
616
+				$where_params['Event.status'] = 'publish';
617
+				if (isset($where_params['DTT_EVT_start'])) {
618
+					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
619
+				}
620
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
621
+					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
622
+				}
623
+				$where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
624
+				$where_params['DTT_EVT_end']   = array('>', $current_time_for_DTT_EVT_end);
625
+				break;
626
+			case 'inactive':
627
+				if (isset($where_params['Event.status'])) {
628
+					unset($where_params['Event.status']);
629
+				}
630
+				if (isset($where_params['OR'])) {
631
+					$where_params['AND']['OR'] = $where_params['OR'];
632
+				}
633
+				if (isset($where_params['DTT_EVT_end'])) {
634
+					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
635
+					unset($where_params['DTT_EVT_end']);
636
+				}
637
+				if (isset($where_params['DTT_EVT_start'])) {
638
+					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
639
+					unset($where_params['DTT_EVT_start']);
640
+				}
641
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
642
+				break;
643
+		}
644
+		$query_params[0]          = $where_params;
645
+		$query_params['group_by'] = array('dtt_year', 'dtt_month');
646
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
647
+		$query_interval           = EEH_DTT_Helper::get_sql_query_interval_for_offset(
648
+			$this->get_timezone(),
649
+			'DTT_EVT_start'
650
+		);
651
+		$columns_to_select        = array(
652
+			'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
653
+			'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
654
+			'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
655
+		);
656
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
657
+	}
658
+
659
+
660
+	/**
661
+	 * Updates the DTT_sold attribute on each datetime (based on the registrations
662
+	 * for the tickets for each datetime)
663
+	 *
664
+	 * @param EE_Base_Class[]|EE_Datetime[] $datetimes
665
+	 * @throws EE_Error
666
+	 */
667
+	public function update_sold($datetimes)
668
+	{
669
+		EE_Error::doing_it_wrong(
670
+			__FUNCTION__,
671
+			esc_html__(
672
+				'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.',
673
+				'event_espresso'
674
+			),
675
+			'4.9.32.rc.005'
676
+		);
677
+		foreach ($datetimes as $datetime) {
678
+			$datetime->update_sold();
679
+		}
680
+	}
681
+
682
+
683
+	/**
684
+	 *    Gets the total number of tickets available at a particular datetime
685
+	 *    (does NOT take into account the datetime's spaces available)
686
+	 *
687
+	 * @param int   $DTT_ID
688
+	 * @param array $query_params
689
+	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO
690
+	 *             tickets attached to datetime then FALSE is returned.
691
+	 */
692
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array())
693
+	{
694
+		$datetime = $this->get_one_by_ID($DTT_ID);
695
+		if ($datetime instanceof EE_Datetime) {
696
+			return $datetime->tickets_remaining($query_params);
697
+		}
698
+		return 0;
699
+	}
700
+
701
+
702
+	/**
703
+	 * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
704
+	 *
705
+	 * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
706
+	 *                                 stati you want counts for as values in the array.  An empty array returns counts
707
+	 *                                 for all valid stati.
708
+	 * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
709
+	 *                                 only for Datetimes connected to a specific event, or specific ticket.
710
+	 * @return array  The value returned is an array indexed by Datetime Status and the values are the counts.  The
711
+	 * @throws EE_Error
712
+	 *                                 stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming
713
+	 *                                 EE_Datetime::expired
714
+	 */
715
+	public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array())
716
+	{
717
+		// only accept where conditions for this query.
718
+		$_where            = isset($query_params[0]) ? $query_params[0] : array();
719
+		$status_query_args = array(
720
+			EE_Datetime::active   => array_merge(
721
+				$_where,
722
+				array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
723
+			),
724
+			EE_Datetime::upcoming => array_merge(
725
+				$_where,
726
+				array('DTT_EVT_start' => array('>', time()))
727
+			),
728
+			EE_Datetime::expired  => array_merge(
729
+				$_where,
730
+				array('DTT_EVT_end' => array('<', time()))
731
+			),
732
+		);
733
+		if (! empty($stati_to_include)) {
734
+			foreach (array_keys($status_query_args) as $status) {
735
+				if (! in_array($status, $stati_to_include, true)) {
736
+					unset($status_query_args[ $status ]);
737
+				}
738
+			}
739
+		}
740
+		// loop through and query counts for each stati.
741
+		$status_query_results = array();
742
+		foreach ($status_query_args as $status => $status_where_conditions) {
743
+			$status_query_results[ $status ] = EEM_Datetime::count(
744
+				array($status_where_conditions),
745
+				'DTT_ID',
746
+				true
747
+			);
748
+		}
749
+		return $status_query_results;
750
+	}
751
+
752
+
753
+	/**
754
+	 * Returns the specific count for a given Datetime status matching any given query_params.
755
+	 *
756
+	 * @param string $status Valid string representation for Datetime status requested. (Defaults to Active).
757
+	 * @param array  $query_params
758
+	 * @return int
759
+	 * @throws EE_Error
760
+	 */
761
+	public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
762
+	{
763
+		$count = $this->get_datetime_counts_by_status(array($status), $query_params);
764
+		return ! empty($count[ $status ]) ? $count[ $status ] : 0;
765
+	}
766 766
 }
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@
 block discarded – undo
22 22
     {
23 23
 
24 24
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
25
-        if (! defined('TXN_PG_SLUG')) {
25
+        if ( ! defined('TXN_PG_SLUG')) {
26 26
             define('TXN_PG_SLUG', 'espresso_transactions');
27 27
             define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
28
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
29
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
30
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
31
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
32
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
33
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
28
+            define('TXN_ADMIN', EE_ADMIN_PAGES.'transactions/');
29
+            define('TXN_ADMIN_URL', admin_url('admin.php?page='.TXN_PG_SLUG));
30
+            define('TXN_ASSETS_PATH', TXN_ADMIN.'assets/');
31
+            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL.'transactions/assets/'));
32
+            define('TXN_TEMPLATE_PATH', TXN_ADMIN.'templates/');
33
+            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL.'transactions/templates/'));
34 34
         }
35 35
         parent::__construct();
36 36
     }
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,58 +11,58 @@
 block discarded – undo
11 11
  */
12 12
 class Transactions_Admin_Page_Init extends EE_Admin_Page_Init
13 13
 {
14
-    /**
15
-     * @Constructor
16
-     * @access public
17
-     * @return Transactions_Admin_Page_Init
18
-     */
19
-    public function __construct()
20
-    {
14
+	/**
15
+	 * @Constructor
16
+	 * @access public
17
+	 * @return Transactions_Admin_Page_Init
18
+	 */
19
+	public function __construct()
20
+	{
21 21
 
22
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
23
-        if (! defined('TXN_PG_SLUG')) {
24
-            define('TXN_PG_SLUG', 'espresso_transactions');
25
-            define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
26
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
27
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
28
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
29
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
30
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
31
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
32
-        }
33
-        parent::__construct();
34
-    }
22
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
23
+		if (! defined('TXN_PG_SLUG')) {
24
+			define('TXN_PG_SLUG', 'espresso_transactions');
25
+			define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
26
+			define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
27
+			define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
28
+			define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
29
+			define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
30
+			define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
31
+			define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
32
+		}
33
+		parent::__construct();
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     *    _set_init_properties
39
-     *
40
-     * @return void
41
-     */
42
-    protected function _set_init_properties()
43
-    {
44
-        $this->label = esc_html__('Transactions Overview', 'event_espresso');
45
-    }
37
+	/**
38
+	 *    _set_init_properties
39
+	 *
40
+	 * @return void
41
+	 */
42
+	protected function _set_init_properties()
43
+	{
44
+		$this->label = esc_html__('Transactions Overview', 'event_espresso');
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     *    _set_menu_map
50
-     *
51
-     * @return void
52
-     */
53
-    protected function _set_menu_map()
54
-    {
55
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
56
-            array(
57
-                'menu_group'      => 'main',
58
-                'menu_order'      => 50,
59
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
60
-                'parent_slug'     => 'espresso_events',
61
-                'menu_slug'       => TXN_PG_SLUG,
62
-                'menu_label'      => esc_html__('Transactions', 'event_espresso'),
63
-                'capability'      => 'ee_read_transactions',
64
-                'admin_init_page' => $this,
65
-            )
66
-        );
67
-    }
48
+	/**
49
+	 *    _set_menu_map
50
+	 *
51
+	 * @return void
52
+	 */
53
+	protected function _set_menu_map()
54
+	{
55
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
56
+			array(
57
+				'menu_group'      => 'main',
58
+				'menu_order'      => 50,
59
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
60
+				'parent_slug'     => 'espresso_events',
61
+				'menu_slug'       => TXN_PG_SLUG,
62
+				'menu_label'      => esc_html__('Transactions', 'event_espresso'),
63
+				'capability'      => 'ee_read_transactions',
64
+				'admin_init_page' => $this,
65
+			)
66
+		);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page_Init.core.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
     {
22 22
         // define some event categories related constants
23 23
         define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
24
+        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page='.EE_VENUES_PG_SLUG));
25
+        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL.'venues/assets/');
26
+        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES.'venues/templates/');
27 27
 
28 28
         parent::__construct();
29
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
29
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
30 30
     }
31 31
 
32 32
     protected function _set_init_properties()
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,39 +15,39 @@
 block discarded – undo
15 15
  */
16 16
 class Venues_Admin_Page_Init extends EE_Admin_Page_CPT_Init
17 17
 {
18
-    public function __construct()
19
-    {
20
-        // define some event categories related constants
21
-        define('EE_VENUES_PG_SLUG', 'espresso_venues');
22
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
23
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
24
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
18
+	public function __construct()
19
+	{
20
+		// define some event categories related constants
21
+		define('EE_VENUES_PG_SLUG', 'espresso_venues');
22
+		define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
23
+		define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
24
+		define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
25 25
 
26
-        parent::__construct();
27
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
28
-    }
26
+		parent::__construct();
27
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
28
+	}
29 29
 
30
-    protected function _set_init_properties()
31
-    {
32
-        $this->label = esc_html__('Event Venues', 'event_espresso');
33
-        $this->menu_label = esc_html__('Venues', 'event_espresso');
34
-        $this->menu_slug = EE_VENUES_PG_SLUG;
35
-    }
30
+	protected function _set_init_properties()
31
+	{
32
+		$this->label = esc_html__('Event Venues', 'event_espresso');
33
+		$this->menu_label = esc_html__('Venues', 'event_espresso');
34
+		$this->menu_slug = EE_VENUES_PG_SLUG;
35
+	}
36 36
 
37 37
 
38
-    protected function _set_menu_map()
39
-    {
40
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
41
-            array(
42
-                'menu_group'      => 'management',
43
-                'menu_order'      => 40,
44
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
45
-                'parent_slug'     => 'espresso_events',
46
-                'menu_slug'       => EE_VENUES_PG_SLUG,
47
-                'menu_label'      => esc_html__('Venues', 'event_espresso'),
48
-                'capability'      => 'ee_read_venues',
49
-                'admin_init_page' => $this,
50
-            )
51
-        );
52
-    }
38
+	protected function _set_menu_map()
39
+	{
40
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
41
+			array(
42
+				'menu_group'      => 'management',
43
+				'menu_order'      => 40,
44
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
45
+				'parent_slug'     => 'espresso_events',
46
+				'menu_slug'       => EE_VENUES_PG_SLUG,
47
+				'menu_label'      => esc_html__('Venues', 'event_espresso'),
48
+				'capability'      => 'ee_read_venues',
49
+				'admin_init_page' => $this,
50
+			)
51
+		);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26 26
 
27
-        if (! defined('EE_MSG_PG_SLUG')) {
27
+        if ( ! defined('EE_MSG_PG_SLUG')) {
28 28
             define('EE_MSG_PG_SLUG', 'espresso_messages');
29 29
             define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
30
+            define('EE_MSG_ADMIN', EE_ADMIN_PAGES.'messages/');
31
+            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page='.EE_MSG_PG_SLUG));
32
+            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN.'assets/');
33
+            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL.'messages/assets/');
34
+            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN.'templates/');
35
+            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'messages/templates/');
36 36
         }
37 37
 
38 38
         parent::__construct();
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,52 +13,52 @@
 block discarded – undo
13 13
  */
14 14
 class Messages_Admin_Page_Init extends EE_Admin_Page_Init
15 15
 {
16
-    /**
17
-     *constructor
18
-     *
19
-     * @Constructor
20
-     * @access public
21
-     * @return void
22
-     */
23
-    public function __construct()
24
-    {
16
+	/**
17
+	 *constructor
18
+	 *
19
+	 * @Constructor
20
+	 * @access public
21
+	 * @return void
22
+	 */
23
+	public function __construct()
24
+	{
25 25
 
26
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
27 27
 
28
-        if (! defined('EE_MSG_PG_SLUG')) {
29
-            define('EE_MSG_PG_SLUG', 'espresso_messages');
30
-            define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
31
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
32
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
33
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
34
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
35
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
36
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
37
-        }
28
+		if (! defined('EE_MSG_PG_SLUG')) {
29
+			define('EE_MSG_PG_SLUG', 'espresso_messages');
30
+			define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
31
+			define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
32
+			define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
33
+			define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
34
+			define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
35
+			define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
36
+			define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
37
+		}
38 38
 
39
-        parent::__construct();
40
-    }
39
+		parent::__construct();
40
+	}
41 41
 
42 42
 
43
-    protected function _set_init_properties()
44
-    {
45
-        $this->label = esc_html__('Messages System', 'event_espresso');
46
-    }
43
+	protected function _set_init_properties()
44
+	{
45
+		$this->label = esc_html__('Messages System', 'event_espresso');
46
+	}
47 47
 
48 48
 
49
-    protected function _set_menu_map()
50
-    {
51
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
52
-            array(
53
-                'menu_group'      => 'management',
54
-                'menu_order'      => 10,
55
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
56
-                'parent_slug'     => 'espresso_events',
57
-                'menu_slug'       => EE_MSG_PG_SLUG,
58
-                'menu_label'      => esc_html__('Messages', 'event_espresso'),
59
-                'capability'      => 'ee_read_global_messages',
60
-                'admin_init_page' => $this,
61
-            )
62
-        );
63
-    }
49
+	protected function _set_menu_map()
50
+	{
51
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
52
+			array(
53
+				'menu_group'      => 'management',
54
+				'menu_order'      => 10,
55
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
56
+				'parent_slug'     => 'espresso_events',
57
+				'menu_slug'       => EE_MSG_PG_SLUG,
58
+				'menu_label'      => esc_html__('Messages', 'event_espresso'),
59
+				'capability'      => 'ee_read_global_messages',
60
+				'admin_init_page' => $this,
61
+			)
62
+		);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@
 block discarded – undo
23 23
     public function __construct()
24 24
     {
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
26
+        if ( ! defined('REG_PG_SLUG')) {
27 27
             define('REG_PG_SLUG', 'espresso_registrations');
28 28
             define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
29
+            define('REG_ADMIN', EE_ADMIN_PAGES.'registrations/');
30
+            define('REG_ADMIN_URL', admin_url('admin.php?page='.REG_PG_SLUG));
31
+            define('REG_ASSETS_PATH', REG_ADMIN.'assets/');
32
+            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL.'registrations/assets/');
33
+            define('REG_TEMPLATE_PATH', REG_ADMIN.'templates/');
34
+            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registrations/templates/');
35 35
         }
36 36
 
37 37
         parent::__construct();
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,50 +11,50 @@
 block discarded – undo
11 11
  */
12 12
 class Registrations_Admin_Page_Init extends EE_Admin_Page_CPT_Init
13 13
 {
14
-    /**
15
-     *        constructor
16
-     *
17
-     * @Constructor
18
-     * @access public
19
-     * @return void
20
-     */
21
-    public function __construct()
22
-    {
23
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
24
-        if (! defined('REG_PG_SLUG')) {
25
-            define('REG_PG_SLUG', 'espresso_registrations');
26
-            define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
27
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
28
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
29
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
30
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
31
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
32
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
33
-        }
14
+	/**
15
+	 *        constructor
16
+	 *
17
+	 * @Constructor
18
+	 * @access public
19
+	 * @return void
20
+	 */
21
+	public function __construct()
22
+	{
23
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
24
+		if (! defined('REG_PG_SLUG')) {
25
+			define('REG_PG_SLUG', 'espresso_registrations');
26
+			define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
27
+			define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
28
+			define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
29
+			define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
30
+			define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
31
+			define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
32
+			define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
33
+		}
34 34
 
35
-        parent::__construct();
36
-    }
35
+		parent::__construct();
36
+	}
37 37
 
38 38
 
39
-    protected function _set_init_properties()
40
-    {
41
-        $this->label = esc_html__('Registrations Overview', 'event_espresso');
42
-    }
39
+	protected function _set_init_properties()
40
+	{
41
+		$this->label = esc_html__('Registrations Overview', 'event_espresso');
42
+	}
43 43
 
44 44
 
45
-    protected function _set_menu_map()
46
-    {
47
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
48
-            array(
49
-                'menu_group'      => 'main',
50
-                'menu_order'      => 40,
51
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
52
-                'parent_slug'     => 'espresso_events',
53
-                'menu_slug'       => REG_PG_SLUG,
54
-                'menu_label'      => esc_html__('Registrations', 'event_espresso'),
55
-                'capability'      => 'ee_read_registrations',
56
-                'admin_init_page' => $this,
57
-            )
58
-        );
59
-    }
45
+	protected function _set_menu_map()
46
+	{
47
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
48
+			array(
49
+				'menu_group'      => 'main',
50
+				'menu_order'      => 40,
51
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
52
+				'parent_slug'     => 'espresso_events',
53
+				'menu_slug'       => REG_PG_SLUG,
54
+				'menu_label'      => esc_html__('Registrations', 'event_espresso'),
55
+				'capability'      => 'ee_read_registrations',
56
+				'admin_init_page' => $this,
57
+			)
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Express();
25 25
 
26 26
         $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
27
+        $this->_template_path = $this->file_folder().'templates/';
28 28
         $this->_default_description = esc_html__(
29 29
             // @codingStandardsIgnoreStart
30 30
             'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31 31
             // @codingStandardsIgnoreEnd
32 32
             'event_espresso'
33 33
         );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34
+        $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36 36
         parent::__construct($pm_instance);
37 37
     }
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -14,89 +14,89 @@
 block discarded – undo
14 14
  */
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base
16 16
 {
17
-    /**
18
-     * EE_PMT_Paypal_Express constructor.
19
-     */
20
-    public function __construct($pm_instance = null)
21
-    {
22
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
-        $this->_gateway = new EEG_Paypal_Express();
17
+	/**
18
+	 * EE_PMT_Paypal_Express constructor.
19
+	 */
20
+	public function __construct($pm_instance = null)
21
+	{
22
+		require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+		$this->_gateway = new EEG_Paypal_Express();
24 24
 
25
-        $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
26
-        $this->_template_path = $this->file_folder() . 'templates/';
27
-        $this->_default_description = esc_html__(
28
-            // @codingStandardsIgnoreStart
29
-            'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
30
-            // @codingStandardsIgnoreEnd
31
-            'event_espresso'
32
-        );
33
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
25
+		$this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
26
+		$this->_template_path = $this->file_folder() . 'templates/';
27
+		$this->_default_description = esc_html__(
28
+			// @codingStandardsIgnoreStart
29
+			'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
30
+			// @codingStandardsIgnoreEnd
31
+			'event_espresso'
32
+		);
33
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34 34
 
35
-        parent::__construct($pm_instance);
36
-    }
35
+		parent::__construct($pm_instance);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Adds the help tab.
41
-     *
42
-     * @see EE_PMT_Base::help_tabs_config()
43
-     * @return array
44
-     */
45
-    public function help_tabs_config()
46
-    {
47
-        return array(
48
-            $this->get_help_tab_name() => array(
49
-                'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
50
-                'filename' => 'payment_methods_overview_paypal_express'
51
-            )
52
-        );
53
-    }
39
+	/**
40
+	 * Adds the help tab.
41
+	 *
42
+	 * @see EE_PMT_Base::help_tabs_config()
43
+	 * @return array
44
+	 */
45
+	public function help_tabs_config()
46
+	{
47
+		return array(
48
+			$this->get_help_tab_name() => array(
49
+				'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
50
+				'filename' => 'payment_methods_overview_paypal_express'
51
+			)
52
+		);
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * Gets the form for all the settings related to this payment method type.
58
-     *
59
-     * @return EE_Payment_Method_Form
60
-     */
61
-    public function generate_new_settings_form()
62
-    {
63
-        return new SettingsForm(array(), $this->get_help_tab_link());
64
-    }
56
+	/**
57
+	 * Gets the form for all the settings related to this payment method type.
58
+	 *
59
+	 * @return EE_Payment_Method_Form
60
+	 */
61
+	public function generate_new_settings_form()
62
+	{
63
+		return new SettingsForm(array(), $this->get_help_tab_link());
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * Creates a billing form for this payment method type.
69
-     *
70
-     * @param \EE_Transaction $transaction
71
-     * @return \EE_Billing_Info_Form
72
-     */
73
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
74
-    {
75
-        if ($this->_pm_instance->debug_mode()) {
76
-            $form = new EE_Billing_Info_Form(
77
-                $this->_pm_instance,
78
-                array(
79
-                    'name' => 'paypal_express_Info_Form',
80
-                    'subsections' => array(
81
-                        'paypal_express_debug_info' => new EE_Form_Section_Proper(
82
-                            array(
83
-                                'layout_strategy' => new EE_Template_Layout(
84
-                                    array(
85
-                                        'layout_template_file' => $this->_template_path
86
-                                                                    . 'paypal_express_debug_info.template.php',
87
-                                        'template_args'        => array(
88
-                                            'debug_mode' => $this->_pm_instance->debug_mode()
89
-                                        )
90
-                                    )
91
-                                )
92
-                            )
93
-                        )
94
-                    )
95
-                )
96
-            );
97
-            return $form;
98
-        }
67
+	/**
68
+	 * Creates a billing form for this payment method type.
69
+	 *
70
+	 * @param \EE_Transaction $transaction
71
+	 * @return \EE_Billing_Info_Form
72
+	 */
73
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
74
+	{
75
+		if ($this->_pm_instance->debug_mode()) {
76
+			$form = new EE_Billing_Info_Form(
77
+				$this->_pm_instance,
78
+				array(
79
+					'name' => 'paypal_express_Info_Form',
80
+					'subsections' => array(
81
+						'paypal_express_debug_info' => new EE_Form_Section_Proper(
82
+							array(
83
+								'layout_strategy' => new EE_Template_Layout(
84
+									array(
85
+										'layout_template_file' => $this->_template_path
86
+																	. 'paypal_express_debug_info.template.php',
87
+										'template_args'        => array(
88
+											'debug_mode' => $this->_pm_instance->debug_mode()
89
+										)
90
+									)
91
+								)
92
+							)
93
+						)
94
+					)
95
+				)
96
+			);
97
+			return $form;
98
+		}
99 99
 
100
-        return false;
101
-    }
100
+		return false;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     {
91 91
         espresso_load_required(
92 92
             'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
93
+            EE_CORE.'request_stack/EE_Request.core.php'
94 94
         );
95 95
         $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96 96
         $this->legacy_request->setRequest($this->request);
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -28,84 +28,84 @@
 block discarded – undo
28 28
  */
29 29
 class BootstrapRequestResponseObjects
30 30
 {
31
-    /**
32
-     * @type LegacyRequestInterface $legacy_request
33
-     */
34
-    protected $legacy_request;
31
+	/**
32
+	 * @type LegacyRequestInterface $legacy_request
33
+	 */
34
+	protected $legacy_request;
35 35
 
36
-    /**
37
-     * @type LoaderInterface $loader
38
-     */
39
-    protected $loader;
36
+	/**
37
+	 * @type LoaderInterface $loader
38
+	 */
39
+	protected $loader;
40 40
 
41
-    /**
42
-     * @var RequestInterface $request
43
-     */
44
-    protected $request;
41
+	/**
42
+	 * @var RequestInterface $request
43
+	 */
44
+	protected $request;
45 45
 
46
-    /**
47
-     * @var ResponseInterface $response
48
-     */
49
-    protected $response;
46
+	/**
47
+	 * @var ResponseInterface $response
48
+	 */
49
+	protected $response;
50 50
 
51 51
 
52
-    /**
53
-     * BootstrapRequestResponseObjects constructor.
54
-     *
55
-     * @param LoaderInterface $loader
56
-     */
57
-    public function __construct(LoaderInterface $loader)
58
-    {
59
-        $this->loader = $loader;
60
-    }
52
+	/**
53
+	 * BootstrapRequestResponseObjects constructor.
54
+	 *
55
+	 * @param LoaderInterface $loader
56
+	 */
57
+	public function __construct(LoaderInterface $loader)
58
+	{
59
+		$this->loader = $loader;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return void
65
-     */
66
-    public function buildRequestResponse()
67
-    {
68
-        $request_params = new RequestParams(new RequestSanitizer());
69
-        $server_params = new ServerParams(new ServerSanitizer());
70
-        // load our Request and Response objects
71
-        $this->request = new Request($request_params, $server_params);
72
-        $this->response = new Response();
73
-        $this->loader->share(RequestParams::class, $request_params);
74
-        $this->loader->share(ServerParams::class, $server_params);
75
-    }
63
+	/**
64
+	 * @return void
65
+	 */
66
+	public function buildRequestResponse()
67
+	{
68
+		$request_params = new RequestParams(new RequestSanitizer());
69
+		$server_params = new ServerParams(new ServerSanitizer());
70
+		// load our Request and Response objects
71
+		$this->request = new Request($request_params, $server_params);
72
+		$this->response = new Response();
73
+		$this->loader->share(RequestParams::class, $request_params);
74
+		$this->loader->share(ServerParams::class, $server_params);
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @return void
80
-     * @throws InvalidArgumentException
81
-     */
82
-    public function shareRequestResponse()
83
-    {
84
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
85
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
86
-        EE_Dependency_Map::instance()->setRequest($this->request);
87
-        EE_Dependency_Map::instance()->setResponse($this->response);
88
-    }
78
+	/**
79
+	 * @return void
80
+	 * @throws InvalidArgumentException
81
+	 */
82
+	public function shareRequestResponse()
83
+	{
84
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
85
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
86
+		EE_Dependency_Map::instance()->setRequest($this->request);
87
+		EE_Dependency_Map::instance()->setResponse($this->response);
88
+	}
89 89
 
90 90
 
91
-    /**
92
-     * @return void
93
-     * @throws InvalidArgumentException
94
-     * @throws EE_Error
95
-     */
96
-    public function setupLegacyRequest()
97
-    {
98
-        espresso_load_required(
99
-            'EE_Request',
100
-            EE_CORE . 'request_stack/EE_Request.core.php'
101
-        );
102
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
103
-        $this->legacy_request->setRequest($this->request);
104
-        $this->legacy_request->admin = $this->request->isAdmin();
105
-        $this->legacy_request->ajax = $this->request->isAjax();
106
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
107
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
108
-        $this->loader->share('EE_Request', $this->legacy_request);
109
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
110
-    }
91
+	/**
92
+	 * @return void
93
+	 * @throws InvalidArgumentException
94
+	 * @throws EE_Error
95
+	 */
96
+	public function setupLegacyRequest()
97
+	{
98
+		espresso_load_required(
99
+			'EE_Request',
100
+			EE_CORE . 'request_stack/EE_Request.core.php'
101
+		);
102
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
103
+		$this->legacy_request->setRequest($this->request);
104
+		$this->legacy_request->admin = $this->request->isAdmin();
105
+		$this->legacy_request->ajax = $this->request->isAjax();
106
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
107
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
108
+		$this->loader->share('EE_Request', $this->legacy_request);
109
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
110
+	}
111 111
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapCore.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         // load interfaces
200 200
         espresso_load_required(
201 201
             'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
202
+            EE_CORE.'helpers/EEH_Autoloader.helper.php'
203 203
         );
204 204
         EEH_Autoloader::instance();
205 205
     }
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
     protected function setAutoloadersForRequiredFiles()
214 214
     {
215 215
         // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
216
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true);
217 217
         // load helpers
218 218
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219 219
         // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
220
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack/');
221 221
         // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
222
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware/');
223 223
     }
224 224
 
225 225
 
Please login to merge, or discard this patch.
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -46,225 +46,225 @@
 block discarded – undo
46 46
  */
47 47
 class BootstrapCore
48 48
 {
49
-    /**
50
-     * @type LoaderInterface $loader
51
-     */
52
-    private $loader;
49
+	/**
50
+	 * @type LoaderInterface $loader
51
+	 */
52
+	private $loader;
53 53
 
54
-    /**
55
-     * @var RequestInterface $request
56
-     */
57
-    protected $request;
54
+	/**
55
+	 * @var RequestInterface $request
56
+	 */
57
+	protected $request;
58 58
 
59
-    /**
60
-     * @var ResponseInterface $response
61
-     */
62
-    protected $response;
59
+	/**
60
+	 * @var ResponseInterface $response
61
+	 */
62
+	protected $response;
63 63
 
64
-    /**
65
-     * @var RequestStackBuilder $request_stack_builder
66
-     */
67
-    protected $request_stack_builder;
64
+	/**
65
+	 * @var RequestStackBuilder $request_stack_builder
66
+	 */
67
+	protected $request_stack_builder;
68 68
 
69
-    /**
70
-     * @var RequestStack $request_stack
71
-     */
72
-    protected $request_stack;
69
+	/**
70
+	 * @var RequestStack $request_stack
71
+	 */
72
+	protected $request_stack;
73 73
 
74 74
 
75
-    /**
76
-     * BootstrapCore constructor.
77
-     */
78
-    public function __construct()
79
-    {
80
-        do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
81
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
82
-        add_action('plugins_loaded', array($this, 'initialize'), 0);
83
-    }
75
+	/**
76
+	 * BootstrapCore constructor.
77
+	 */
78
+	public function __construct()
79
+	{
80
+		do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
81
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
82
+		add_action('plugins_loaded', array($this, 'initialize'), 0);
83
+	}
84 84
 
85 85
 
86
-    /**
87
-     * @throws DomainException
88
-     * @throws EE_Error
89
-     * @throws Exception
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidClassException
92
-     * @throws InvalidDataTypeException
93
-     * @throws InvalidFilePathException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidRequestStackMiddlewareException
96
-     * @throws OutOfBoundsException
97
-     * @throws ReflectionException
98
-     */
99
-    public function initialize()
100
-    {
101
-        $this->bootstrapDependencyInjectionContainer();
102
-        $this->bootstrapDomain();
103
-        $bootstrap_request = $this->bootstrapRequestResponseObjects();
104
-        add_action(
105
-            'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
106
-            array($bootstrap_request, 'setupLegacyRequest')
107
-        );
108
-        $this->runRequestStack();
109
-    }
86
+	/**
87
+	 * @throws DomainException
88
+	 * @throws EE_Error
89
+	 * @throws Exception
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidClassException
92
+	 * @throws InvalidDataTypeException
93
+	 * @throws InvalidFilePathException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidRequestStackMiddlewareException
96
+	 * @throws OutOfBoundsException
97
+	 * @throws ReflectionException
98
+	 */
99
+	public function initialize()
100
+	{
101
+		$this->bootstrapDependencyInjectionContainer();
102
+		$this->bootstrapDomain();
103
+		$bootstrap_request = $this->bootstrapRequestResponseObjects();
104
+		add_action(
105
+			'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
106
+			array($bootstrap_request, 'setupLegacyRequest')
107
+		);
108
+		$this->runRequestStack();
109
+	}
110 110
 
111 111
 
112
-    /**
113
-     * @throws ReflectionException
114
-     * @throws EE_Error
115
-     * @throws InvalidArgumentException
116
-     * @throws InvalidDataTypeException
117
-     * @throws InvalidInterfaceException
118
-     * @throws OutOfBoundsException
119
-     */
120
-    private function bootstrapDependencyInjectionContainer()
121
-    {
122
-        $bootstrap_di = new BootstrapDependencyInjectionContainer();
123
-        $bootstrap_di->buildLegacyDependencyInjectionContainer();
124
-        $bootstrap_di->buildLoader();
125
-        $registry = $bootstrap_di->getRegistry();
126
-        $dependency_map = $bootstrap_di->getDependencyMap();
127
-        $dependency_map->initialize();
128
-        $registry->initialize();
129
-        $this->loader = $bootstrap_di->getLoader();
130
-    }
112
+	/**
113
+	 * @throws ReflectionException
114
+	 * @throws EE_Error
115
+	 * @throws InvalidArgumentException
116
+	 * @throws InvalidDataTypeException
117
+	 * @throws InvalidInterfaceException
118
+	 * @throws OutOfBoundsException
119
+	 */
120
+	private function bootstrapDependencyInjectionContainer()
121
+	{
122
+		$bootstrap_di = new BootstrapDependencyInjectionContainer();
123
+		$bootstrap_di->buildLegacyDependencyInjectionContainer();
124
+		$bootstrap_di->buildLoader();
125
+		$registry = $bootstrap_di->getRegistry();
126
+		$dependency_map = $bootstrap_di->getDependencyMap();
127
+		$dependency_map->initialize();
128
+		$registry->initialize();
129
+		$this->loader = $bootstrap_di->getLoader();
130
+	}
131 131
 
132 132
 
133
-    /**
134
-     * configures the Domain object for core
135
-     *
136
-     * @return void
137
-     * @throws DomainException
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidClassException
141
-     * @throws InvalidFilePathException
142
-     * @throws InvalidInterfaceException
143
-     */
144
-    private function bootstrapDomain()
145
-    {
146
-        DomainFactory::getEventEspressoCoreDomain();
147
-    }
133
+	/**
134
+	 * configures the Domain object for core
135
+	 *
136
+	 * @return void
137
+	 * @throws DomainException
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidClassException
141
+	 * @throws InvalidFilePathException
142
+	 * @throws InvalidInterfaceException
143
+	 */
144
+	private function bootstrapDomain()
145
+	{
146
+		DomainFactory::getEventEspressoCoreDomain();
147
+	}
148 148
 
149 149
 
150
-    /**
151
-     * sets up the request and response objects
152
-     *
153
-     * @return BootstrapRequestResponseObjects
154
-     * @throws InvalidArgumentException
155
-     */
156
-    private function bootstrapRequestResponseObjects()
157
-    {
158
-        /** @var BootstrapRequestResponseObjects $bootstrap_request */
159
-        $bootstrap_request = $this->loader->getShared(
160
-            'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
161
-            array($this->loader)
162
-        );
163
-        $bootstrap_request->buildRequestResponse();
164
-        $bootstrap_request->shareRequestResponse();
165
-        $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
166
-        $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
167
-        return $bootstrap_request;
168
-    }
150
+	/**
151
+	 * sets up the request and response objects
152
+	 *
153
+	 * @return BootstrapRequestResponseObjects
154
+	 * @throws InvalidArgumentException
155
+	 */
156
+	private function bootstrapRequestResponseObjects()
157
+	{
158
+		/** @var BootstrapRequestResponseObjects $bootstrap_request */
159
+		$bootstrap_request = $this->loader->getShared(
160
+			'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
161
+			array($this->loader)
162
+		);
163
+		$bootstrap_request->buildRequestResponse();
164
+		$bootstrap_request->shareRequestResponse();
165
+		$this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
166
+		$this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
167
+		return $bootstrap_request;
168
+	}
169 169
 
170 170
 
171
-    /**
172
-     * run_request_stack
173
-     * construct request stack and run middleware apps
174
-     *
175
-     * @throws EE_Error
176
-     * @throws Exception
177
-     */
178
-    public function runRequestStack()
179
-    {
180
-        $this->loadAutoloader();
181
-        $this->setAutoloadersForRequiredFiles();
182
-        $this->request_stack_builder = $this->buildRequestStack();
183
-        $this->request_stack = $this->request_stack_builder->resolve(
184
-            new RequestStackCoreApp()
185
-        );
186
-        $this->request_stack->handleRequest($this->request, $this->response);
187
-        $this->request_stack->handleResponse();
188
-    }
171
+	/**
172
+	 * run_request_stack
173
+	 * construct request stack and run middleware apps
174
+	 *
175
+	 * @throws EE_Error
176
+	 * @throws Exception
177
+	 */
178
+	public function runRequestStack()
179
+	{
180
+		$this->loadAutoloader();
181
+		$this->setAutoloadersForRequiredFiles();
182
+		$this->request_stack_builder = $this->buildRequestStack();
183
+		$this->request_stack = $this->request_stack_builder->resolve(
184
+			new RequestStackCoreApp()
185
+		);
186
+		$this->request_stack->handleRequest($this->request, $this->response);
187
+		$this->request_stack->handleResponse();
188
+	}
189 189
 
190 190
 
191
-    /**
192
-     * load_autoloader
193
-     *
194
-     * @throws EE_Error
195
-     */
196
-    protected function loadAutoloader()
197
-    {
198
-        // load interfaces
199
-        espresso_load_required(
200
-            'EEH_Autoloader',
201
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
202
-        );
203
-        EEH_Autoloader::instance();
204
-    }
191
+	/**
192
+	 * load_autoloader
193
+	 *
194
+	 * @throws EE_Error
195
+	 */
196
+	protected function loadAutoloader()
197
+	{
198
+		// load interfaces
199
+		espresso_load_required(
200
+			'EEH_Autoloader',
201
+			EE_CORE . 'helpers/EEH_Autoloader.helper.php'
202
+		);
203
+		EEH_Autoloader::instance();
204
+	}
205 205
 
206 206
 
207
-    /**
208
-     * load_required_files
209
-     *
210
-     * @throws EE_Error
211
-     */
212
-    protected function setAutoloadersForRequiredFiles()
213
-    {
214
-        // load interfaces
215
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
216
-        // load helpers
217
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
218
-        // register legacy request stack classes just in case
219
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
220
-        // register legacy middleware classes just in case
221
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
222
-    }
207
+	/**
208
+	 * load_required_files
209
+	 *
210
+	 * @throws EE_Error
211
+	 */
212
+	protected function setAutoloadersForRequiredFiles()
213
+	{
214
+		// load interfaces
215
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
216
+		// load helpers
217
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
218
+		// register legacy request stack classes just in case
219
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
220
+		// register legacy middleware classes just in case
221
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * build_request_stack
227
-     *
228
-     * @return RequestStackBuilder
229
-     */
230
-    public function buildRequestStack()
231
-    {
232
-        $request_stack_builder = new RequestStackBuilder($this->loader);
233
-        /**
234
-         * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
235
-         * so items at the beginning of the final middleware stack will run last.
236
-         * First parameter is the middleware classname, second is an array of arguments
237
-         */
238
-        $stack_apps = apply_filters(
239
-            'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
240
-            array(
241
-                // first in last out
242
-                'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
243
-                'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
244
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
245
-                'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
246
-                // last in first out
247
-                'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
248
-            )
249
-        );
250
-        // legacy filter for backwards compatibility
251
-        $stack_apps = apply_filters(
252
-            'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
253
-            $stack_apps
254
-        );
255
-        // load middleware onto stack : FILO (First In Last Out)
256
-        // items at the beginning of the $stack_apps array will run last
257
-        foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
258
-            $request_stack_builder->push(array($stack_app, $stack_app_args));
259
-        }
260
-        // finally, we'll add this on its own because we need it to always be part of the stack
261
-        // and we also need it to always run first because the rest of the system relies on it
262
-        $request_stack_builder->push(
263
-            array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
264
-        );
265
-        return apply_filters(
266
-            'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
267
-            $request_stack_builder
268
-        );
269
-    }
225
+	/**
226
+	 * build_request_stack
227
+	 *
228
+	 * @return RequestStackBuilder
229
+	 */
230
+	public function buildRequestStack()
231
+	{
232
+		$request_stack_builder = new RequestStackBuilder($this->loader);
233
+		/**
234
+		 * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
235
+		 * so items at the beginning of the final middleware stack will run last.
236
+		 * First parameter is the middleware classname, second is an array of arguments
237
+		 */
238
+		$stack_apps = apply_filters(
239
+			'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
240
+			array(
241
+				// first in last out
242
+				'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
243
+				'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
244
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
245
+				'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
246
+				// last in first out
247
+				'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
248
+			)
249
+		);
250
+		// legacy filter for backwards compatibility
251
+		$stack_apps = apply_filters(
252
+			'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
253
+			$stack_apps
254
+		);
255
+		// load middleware onto stack : FILO (First In Last Out)
256
+		// items at the beginning of the $stack_apps array will run last
257
+		foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
258
+			$request_stack_builder->push(array($stack_app, $stack_app_args));
259
+		}
260
+		// finally, we'll add this on its own because we need it to always be part of the stack
261
+		// and we also need it to always run first because the rest of the system relies on it
262
+		$request_stack_builder->push(
263
+			array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
264
+		);
265
+		return apply_filters(
266
+			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
267
+			$request_stack_builder
268
+		);
269
+	}
270 270
 }
Please login to merge, or discard this patch.
core/services/container/OpenCoffeeShop.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
                 array(),
130 130
                 CoffeeMaker::BREW_LOAD_ONLY,
131 131
                 array(
132
-                    EE_INTERFACES . '*.php',
133
-                    EE_INTERFACES . '*.interfaces.php',
132
+                    EE_INTERFACES.'*.php',
133
+                    EE_INTERFACES.'*.interfaces.php',
134 134
                 )
135 135
             )
136 136
         );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                 array(),
143 143
                 array(),
144 144
                 CoffeeMaker::BREW_SHARED,
145
-                EE_MODELS . '*.model.php'
145
+                EE_MODELS.'*.model.php'
146 146
             )
147 147
         );
148 148
         // add a wildcard recipe for loading core classes
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
                 array(),
155 155
                 CoffeeMaker::BREW_SHARED,
156 156
                 array(
157
-                    EE_CORE . '*.core.php',
158
-                    EE_ADMIN . '*.core.php',
159
-                    EE_CPTS . '*.core.php',
160
-                    EE_CORE . 'data_migration_scripts/*.core.php',
157
+                    EE_CORE.'*.core.php',
158
+                    EE_ADMIN.'*.core.php',
159
+                    EE_CPTS.'*.core.php',
160
+                    EE_CORE.'data_migration_scripts/*.core.php',
161 161
                 )
162 162
             )
163 163
         );
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
                 array(),
170 170
                 array(),
171 171
                 CoffeeMaker::BREW_LOAD_ONLY,
172
-                array(EE_ADMIN . '*.core.php')
172
+                array(EE_ADMIN.'*.core.php')
173 173
             )
174 174
         );
175 175
         // add a wildcard recipe for loading core classes
Please login to merge, or discard this patch.
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -19,192 +19,192 @@
 block discarded – undo
19 19
  */
20 20
 class OpenCoffeeShop
21 21
 {
22
-    /**
23
-     * @var CoffeeShop $CoffeeShop
24
-     */
25
-    private $CoffeeShop;
22
+	/**
23
+	 * @var CoffeeShop $CoffeeShop
24
+	 */
25
+	private $CoffeeShop;
26 26
 
27 27
 
28
-    /**
29
-     * OpenCoffeeShop constructor
30
-     *
31
-     * @throws InvalidInterfaceException
32
-     */
33
-    public function __construct()
34
-    {
35
-        // instantiate the DI container
36
-        $this->CoffeeShop = new CoffeeShop();
37
-    }
28
+	/**
29
+	 * OpenCoffeeShop constructor
30
+	 *
31
+	 * @throws InvalidInterfaceException
32
+	 */
33
+	public function __construct()
34
+	{
35
+		// instantiate the DI container
36
+		$this->CoffeeShop = new CoffeeShop();
37
+	}
38 38
 
39 39
 
40
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
41
-    /**
42
-     * @return CoffeeShop
43
-     */
44
-    public function CoffeeShop()
45
-    {
46
-        return $this->CoffeeShop;
47
-    }
40
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
41
+	/**
42
+	 * @return CoffeeShop
43
+	 */
44
+	public function CoffeeShop()
45
+	{
46
+		return $this->CoffeeShop;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * configure coffee makers which control the different kinds of brews
52
-     * ( shared services, new factory objects, etc )
53
-     *
54
-     * @throws InvalidEntityException
55
-     */
56
-    public function setupCoffeeMakers()
57
-    {
58
-        // create a dependency injector class for resolving class constructor arguments
59
-        $DependencyInjector = new DependencyInjector(
60
-            $this->CoffeeShop,
61
-            new \EEH_Array()
62
-        );
63
-        // and some coffeemakers, one for creating new instances
64
-        $this->CoffeeShop->addCoffeeMaker(
65
-            new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
66
-            CoffeeMaker::BREW_NEW
67
-        );
68
-        // one for shared services
69
-        $this->CoffeeShop->addCoffeeMaker(
70
-            new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
71
-            CoffeeMaker::BREW_SHARED
72
-        );
73
-        // and one for classes that only get loaded
74
-        $this->CoffeeShop->addCoffeeMaker(
75
-            new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
76
-            CoffeeMaker::BREW_LOAD_ONLY
77
-        );
78
-    }
50
+	/**
51
+	 * configure coffee makers which control the different kinds of brews
52
+	 * ( shared services, new factory objects, etc )
53
+	 *
54
+	 * @throws InvalidEntityException
55
+	 */
56
+	public function setupCoffeeMakers()
57
+	{
58
+		// create a dependency injector class for resolving class constructor arguments
59
+		$DependencyInjector = new DependencyInjector(
60
+			$this->CoffeeShop,
61
+			new \EEH_Array()
62
+		);
63
+		// and some coffeemakers, one for creating new instances
64
+		$this->CoffeeShop->addCoffeeMaker(
65
+			new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
66
+			CoffeeMaker::BREW_NEW
67
+		);
68
+		// one for shared services
69
+		$this->CoffeeShop->addCoffeeMaker(
70
+			new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
71
+			CoffeeMaker::BREW_SHARED
72
+		);
73
+		// and one for classes that only get loaded
74
+		$this->CoffeeShop->addCoffeeMaker(
75
+			new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
76
+			CoffeeMaker::BREW_LOAD_ONLY
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Recipes define how to load legacy classes
83
-     *
84
-     * @throws InvalidIdentifierException
85
-     */
86
-    public function addRecipes()
87
-    {
88
-        // add default recipe, which should handle loading for most PSR-4 compatible classes
89
-        // as long as they are not type hinting for interfaces
90
-        $this->CoffeeShop->addRecipe(
91
-            new Recipe(
92
-                Recipe::DEFAULT_ID
93
-            )
94
-        );
95
-        // PSR-4 compatible class with aliases
96
-        $this->CoffeeShop->addRecipe(
97
-            new Recipe(
98
-                'CommandHandlerManager',
99
-                'EventEspresso\core\services\commands\CommandHandlerManager',
100
-                array(
101
-                    'CommandHandlerManagerInterface',
102
-                    'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
103
-                ),
104
-                array(),
105
-                CoffeeMaker::BREW_SHARED
106
-            )
107
-        );
108
-        // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
109
-        $this->CoffeeShop->addRecipe(
110
-            new Recipe(
111
-                'CommandBus',
112
-                'EventEspresso\core\services\commands\CommandBus',
113
-                array(
114
-                    'CommandBusInterface',
115
-                    'EventEspresso\core\services\commands\CommandBusInterface',
116
-                ),
117
-                array(),
118
-                CoffeeMaker::BREW_SHARED
119
-            )
120
-        );
121
-        // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
122
-        // add a wildcard recipe for loading legacy core interfaces
123
-        $this->CoffeeShop->addRecipe(
124
-            new Recipe(
125
-                'EEI_*',
126
-                '',
127
-                array(),
128
-                array(),
129
-                CoffeeMaker::BREW_LOAD_ONLY,
130
-                array(
131
-                    EE_INTERFACES . '*.php',
132
-                    EE_INTERFACES . '*.interfaces.php',
133
-                )
134
-            )
135
-        );
136
-        // add a wildcard recipe for loading models
137
-        $this->CoffeeShop->addRecipe(
138
-            new Recipe(
139
-                'EEM_*',
140
-                '',
141
-                array(),
142
-                array(),
143
-                CoffeeMaker::BREW_SHARED,
144
-                EE_MODELS . '*.model.php'
145
-            )
146
-        );
147
-        // add a wildcard recipe for loading core classes
148
-        $this->CoffeeShop->addRecipe(
149
-            new Recipe(
150
-                'EE_*',
151
-                '',
152
-                array(),
153
-                array(),
154
-                CoffeeMaker::BREW_SHARED,
155
-                array(
156
-                    EE_CORE . '*.core.php',
157
-                    EE_ADMIN . '*.core.php',
158
-                    EE_CPTS . '*.core.php',
159
-                    EE_CORE . 'data_migration_scripts/*.core.php',
160
-                )
161
-            )
162
-        );
163
-        // load admin page parent class
164
-        $this->CoffeeShop->addRecipe(
165
-            new Recipe(
166
-                'EE_Admin_Page*',
167
-                '',
168
-                array(),
169
-                array(),
170
-                CoffeeMaker::BREW_LOAD_ONLY,
171
-                array(EE_ADMIN . '*.core.php')
172
-            )
173
-        );
174
-        // add a wildcard recipe for loading core classes
175
-        // $this->CoffeeShop->addRecipe(
176
-        //     new Recipe(
177
-        //         '*_Admin_Page',
178
-        //         '',
179
-        //         array(),
180
-        //         array(),
181
-        //         CoffeeMaker::BREW_SHARED,
182
-        //         array(
183
-        //             EE_ADMIN_PAGES . 'transactions/*.core.php',
184
-        //         )
185
-        //     )
186
-        // );
187
-    }
81
+	/**
82
+	 * Recipes define how to load legacy classes
83
+	 *
84
+	 * @throws InvalidIdentifierException
85
+	 */
86
+	public function addRecipes()
87
+	{
88
+		// add default recipe, which should handle loading for most PSR-4 compatible classes
89
+		// as long as they are not type hinting for interfaces
90
+		$this->CoffeeShop->addRecipe(
91
+			new Recipe(
92
+				Recipe::DEFAULT_ID
93
+			)
94
+		);
95
+		// PSR-4 compatible class with aliases
96
+		$this->CoffeeShop->addRecipe(
97
+			new Recipe(
98
+				'CommandHandlerManager',
99
+				'EventEspresso\core\services\commands\CommandHandlerManager',
100
+				array(
101
+					'CommandHandlerManagerInterface',
102
+					'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
103
+				),
104
+				array(),
105
+				CoffeeMaker::BREW_SHARED
106
+			)
107
+		);
108
+		// PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
109
+		$this->CoffeeShop->addRecipe(
110
+			new Recipe(
111
+				'CommandBus',
112
+				'EventEspresso\core\services\commands\CommandBus',
113
+				array(
114
+					'CommandBusInterface',
115
+					'EventEspresso\core\services\commands\CommandBusInterface',
116
+				),
117
+				array(),
118
+				CoffeeMaker::BREW_SHARED
119
+			)
120
+		);
121
+		// LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
122
+		// add a wildcard recipe for loading legacy core interfaces
123
+		$this->CoffeeShop->addRecipe(
124
+			new Recipe(
125
+				'EEI_*',
126
+				'',
127
+				array(),
128
+				array(),
129
+				CoffeeMaker::BREW_LOAD_ONLY,
130
+				array(
131
+					EE_INTERFACES . '*.php',
132
+					EE_INTERFACES . '*.interfaces.php',
133
+				)
134
+			)
135
+		);
136
+		// add a wildcard recipe for loading models
137
+		$this->CoffeeShop->addRecipe(
138
+			new Recipe(
139
+				'EEM_*',
140
+				'',
141
+				array(),
142
+				array(),
143
+				CoffeeMaker::BREW_SHARED,
144
+				EE_MODELS . '*.model.php'
145
+			)
146
+		);
147
+		// add a wildcard recipe for loading core classes
148
+		$this->CoffeeShop->addRecipe(
149
+			new Recipe(
150
+				'EE_*',
151
+				'',
152
+				array(),
153
+				array(),
154
+				CoffeeMaker::BREW_SHARED,
155
+				array(
156
+					EE_CORE . '*.core.php',
157
+					EE_ADMIN . '*.core.php',
158
+					EE_CPTS . '*.core.php',
159
+					EE_CORE . 'data_migration_scripts/*.core.php',
160
+				)
161
+			)
162
+		);
163
+		// load admin page parent class
164
+		$this->CoffeeShop->addRecipe(
165
+			new Recipe(
166
+				'EE_Admin_Page*',
167
+				'',
168
+				array(),
169
+				array(),
170
+				CoffeeMaker::BREW_LOAD_ONLY,
171
+				array(EE_ADMIN . '*.core.php')
172
+			)
173
+		);
174
+		// add a wildcard recipe for loading core classes
175
+		// $this->CoffeeShop->addRecipe(
176
+		//     new Recipe(
177
+		//         '*_Admin_Page',
178
+		//         '',
179
+		//         array(),
180
+		//         array(),
181
+		//         CoffeeMaker::BREW_SHARED,
182
+		//         array(
183
+		//             EE_ADMIN_PAGES . 'transactions/*.core.php',
184
+		//         )
185
+		//     )
186
+		// );
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * bootstrap EE and the request stack
192
-     *
193
-     * @throws ServiceNotFoundException
194
-     * @throws InvalidClassException
195
-     * @throws InvalidDataTypeException
196
-     * @throws InvalidIdentifierException
197
-     * @throws exceptions\ServiceExistsException
198
-     * @throws OutOfBoundsException
199
-     * @throws exceptions\InstantiationException
200
-     */
201
-    public function firstBrew()
202
-    {
203
-        $this->CoffeeShop->brew(
204
-            'EventEspresso\core\services\request\Request',
205
-            array($_GET, $_POST, $_COOKIE, $_SERVER)
206
-        );
207
-        $this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
208
-        $this->CoffeeShop->brew('EE_Bootstrap');
209
-    }
190
+	/**
191
+	 * bootstrap EE and the request stack
192
+	 *
193
+	 * @throws ServiceNotFoundException
194
+	 * @throws InvalidClassException
195
+	 * @throws InvalidDataTypeException
196
+	 * @throws InvalidIdentifierException
197
+	 * @throws exceptions\ServiceExistsException
198
+	 * @throws OutOfBoundsException
199
+	 * @throws exceptions\InstantiationException
200
+	 */
201
+	public function firstBrew()
202
+	{
203
+		$this->CoffeeShop->brew(
204
+			'EventEspresso\core\services\request\Request',
205
+			array($_GET, $_POST, $_COOKIE, $_SERVER)
206
+		);
207
+		$this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
208
+		$this->CoffeeShop->brew('EE_Bootstrap');
209
+	}
210 210
 }
Please login to merge, or discard this patch.