Completed
Branch dev (08e10f)
by
unknown
12:20 queued 10:12
created
core/services/admin/AdminPageHeaderDecorator.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@
 block discarded – undo
16 16
 abstract class AdminPageHeaderDecorator implements AdminPageHeaderDecoratorInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var RequestInterface $request
21
-     */
22
-    protected $request;
19
+	/**
20
+	 * @var RequestInterface $request
21
+	 */
22
+	protected $request;
23 23
 
24 24
 
25
-    /**
26
-     * AdminPageHeader constructor.
27
-     *
28
-     * @param RequestInterface $request
29
-     */
30
-    public function __construct(RequestInterface $request)
31
-    {
32
-        $this->request = $request;
33
-    }
25
+	/**
26
+	 * AdminPageHeader constructor.
27
+	 *
28
+	 * @param RequestInterface $request
29
+	 */
30
+	public function __construct(RequestInterface $request)
31
+	{
32
+		$this->request = $request;
33
+	}
34 34
 }
Please login to merge, or discard this patch.
core/domain/services/admin/registrations/list_table/QueryBuilder.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'caps'                     => EEM_Registration::caps_read_admin,
83 83
             'default_where_conditions' => 'this_model_only',
84 84
         ];
85
-        if (! $count_query) {
85
+        if ( ! $count_query) {
86 86
             $query_params = array_merge(
87 87
                 $query_params,
88 88
                 $this->getOrderbyClause(),
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
                 [
229 229
                     $this->registration_model->convert_datetime_for_query(
230 230
                         'REG_date',
231
-                        $now . ' 00:00:00',
231
+                        $now.' 00:00:00',
232 232
                         'Y-m-d H:i:s'
233 233
                     ),
234 234
                     $this->registration_model->convert_datetime_for_query(
235 235
                         'REG_date',
236
-                        $now . ' 23:59:59',
236
+                        $now.' 23:59:59',
237 237
                         'Y-m-d H:i:s'
238 238
                     ),
239 239
                 ],
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                 [
249 249
                     $this->registration_model->convert_datetime_for_query(
250 250
                         'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
251
+                        $current_year_and_month.'-01 00:00:00',
252 252
                         'Y-m-d H:i:s'
253 253
                     ),
254 254
                     $this->registration_model->convert_datetime_for_query(
255 255
                         'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
256
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
257 257
                         'Y-m-d H:i:s'
258 258
                     ),
259 259
                 ],
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
                 : '';
273 273
             // if there is not a month or year then we can't go further
274 274
             if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
275
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
276 276
                 $this->where_params['REG_date'] = [
277 277
                     'BETWEEN',
278 278
                     [
279 279
                         $this->registration_model->convert_datetime_for_query(
280 280
                             'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
281
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
282 282
                             'Y-m-d H:i:s'
283 283
                         ),
284 284
                         $this->registration_model->convert_datetime_for_query(
285 285
                             'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
286
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
287 287
                             'Y-m-d H:i:s'
288 288
                         ),
289 289
                     ],
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         $search = $this->request->getRequestParam('s');
302 302
         if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
303
+            $search_string = '%'.sanitize_text_field($search).'%';
304 304
             $this->where_params['OR*search_conditions'] = [
305 305
                 'Event.EVT_name'                          => ['LIKE', $search_string],
306 306
                 'Event.EVT_desc'                          => ['LIKE', $search_string],
Please login to merge, or discard this patch.
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -21,382 +21,382 @@
 block discarded – undo
21 21
 class QueryBuilder
22 22
 {
23 23
 
24
-    /**
25
-     * @var RequestInterface $request
26
-     */
27
-    protected $request;
28
-
29
-    /**
30
-     * @var EEM_Registration $registration_model
31
-     */
32
-    protected $registration_model;
33
-
34
-    /**
35
-     * @var string $view
36
-     */
37
-    protected $view;
38
-
39
-    /**
40
-     * @var array $where_params
41
-     */
42
-    protected $where_params;
43
-
44
-
45
-    /**
46
-     * QueryBuilder constructor.
47
-     *
48
-     * @param RequestInterface $request
49
-     * @param EEM_Registration $registration_model
50
-     * @param array            $extra_request_params
51
-     */
52
-    public function __construct(
53
-        RequestInterface $request,
54
-        EEM_Registration $registration_model,
55
-        array $extra_request_params = []
56
-    ) {
57
-        $this->request = $request;
58
-        $this->registration_model = $registration_model;
59
-        foreach ($extra_request_params as $key => $value) {
60
-            $this->request->setRequestParam($key, $value);
61
-        }
62
-        $this->view = $this->request->getRequestParam('status', '');
63
-        $this->where_params = [];
64
-    }
65
-
66
-
67
-    /**
68
-     * Sets up the where conditions for the registrations query.
69
-     *
70
-     * @param int  $per_page
71
-     * @param bool $count_query
72
-     * @return array
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     */
78
-    public function getQueryParams($per_page = 10, $count_query = false)
79
-    {
80
-        $query_params = [
81
-            0                          => $this->getWhereClause(),
82
-            'caps'                     => EEM_Registration::caps_read_admin,
83
-            'default_where_conditions' => 'this_model_only',
84
-        ];
85
-        if (! $count_query) {
86
-            $query_params = array_merge(
87
-                $query_params,
88
-                $this->getOrderbyClause(),
89
-                $this->getLimitClause($per_page)
90
-            );
91
-        }
92
-
93
-        return $query_params;
94
-    }
95
-
96
-
97
-    /**
98
-     * Sets up the where conditions for the registrations query.
99
-     *
100
-     * @return array
101
-     * @throws EE_Error
102
-     * @throws InvalidArgumentException
103
-     * @throws InvalidDataTypeException
104
-     * @throws InvalidInterfaceException
105
-     */
106
-    protected function getWhereClause()
107
-    {
108
-        $this->addAttendeeIdToWhereConditions();
109
-        $this->addEventIdToWhereConditions();
110
-        $this->addCategoryIdToWhereConditions();
111
-        $this->addDatetimeIdToWhereConditions();
112
-        $this->addTicketIdToWhereConditions();
113
-        $this->addRegistrationStatusToWhereConditions();
114
-        $this->addDateToWhereConditions();
115
-        $this->addSearchToWhereConditions();
116
-        return apply_filters(
117
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
-            $this->where_params,
119
-            $this->request->requestParams()
120
-        );
121
-    }
122
-
123
-
124
-    /**
125
-     * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
-     */
127
-    protected function addAttendeeIdToWhereConditions()
128
-    {
129
-        $ATT_ID = $this->request->getRequestParam('attendee_id');
130
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID, 'int');
131
-        if ($ATT_ID) {
132
-            $this->where_params['ATT_ID'] = $ATT_ID;
133
-        }
134
-    }
135
-
136
-
137
-    /**
138
-     * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
-     */
140
-    protected function addEventIdToWhereConditions()
141
-    {
142
-        $EVT_ID = $this->request->getRequestParam('event_id');
143
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID, 'int');
144
-        if ($EVT_ID) {
145
-            $this->where_params['EVT_ID'] = $EVT_ID;
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
-     */
153
-    protected function addCategoryIdToWhereConditions()
154
-    {
155
-        $EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT', 0, 'int');
156
-        if ($EVT_CAT > 0) {
157
-            $this->where_params['Event.Term_Taxonomy.term_id'] = $EVT_CAT;
158
-        }
159
-    }
160
-
161
-
162
-    /**
163
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
-     */
165
-    protected function addDatetimeIdToWhereConditions()
166
-    {
167
-        // first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
-        $DTT_ID = $this->request->getRequestParam('datetime_id');
169
-        $DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID, 'int');
170
-        if ($DTT_ID) {
171
-            $this->where_params['Ticket.Datetime.DTT_ID'] = $DTT_ID;
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
-     */
179
-    protected function addTicketIdToWhereConditions()
180
-    {
181
-        // first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
-        $TKT_ID = $this->request->getRequestParam('ticket_id');
183
-        $TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID, 'int');
184
-        if ($TKT_ID) {
185
-            $this->where_params['TKT_ID'] = $TKT_ID;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * Adds the correct registration status to the where conditions for the registrations query.
192
-     * If filtering by registration status, then we show registrations matching that status.
193
-     * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
-     * UNLESS viewing trashed registrations.
195
-     */
196
-    protected function addRegistrationStatusToWhereConditions()
197
-    {
198
-        $registration_status = $this->request->getRequestParam('_reg_status');
199
-        if ($registration_status) {
200
-            $this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
-            return;
202
-        }
203
-        // make sure we exclude incomplete registrations, but only if not trashed.
204
-        if ($this->view === 'trash') {
205
-            $this->where_params['REG_deleted'] = true;
206
-            return;
207
-        }
208
-        $this->where_params['STS_ID'] = $this->view === 'incomplete'
209
-            ? EEM_Registration::status_id_incomplete
210
-            : ['!=', EEM_Registration::status_id_incomplete];
211
-    }
212
-
213
-
214
-    /**
215
-     * Adds any provided date restraints to the where conditions for the registrations query.
216
-     *
217
-     * @throws EE_Error
218
-     * @throws InvalidArgumentException
219
-     * @throws InvalidDataTypeException
220
-     * @throws InvalidInterfaceException
221
-     */
222
-    protected function addDateToWhereConditions()
223
-    {
224
-        if ($this->view === 'today') {
225
-            $now = date('Y-m-d', current_time('timestamp'));
226
-            $this->where_params['REG_date'] = [
227
-                'BETWEEN',
228
-                [
229
-                    $this->registration_model->convert_datetime_for_query(
230
-                        'REG_date',
231
-                        $now . ' 00:00:00',
232
-                        'Y-m-d H:i:s'
233
-                    ),
234
-                    $this->registration_model->convert_datetime_for_query(
235
-                        'REG_date',
236
-                        $now . ' 23:59:59',
237
-                        'Y-m-d H:i:s'
238
-                    ),
239
-                ],
240
-            ];
241
-            return;
242
-        }
243
-        if ($this->view === 'month') {
244
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
245
-            $days_this_month = date('t', current_time('timestamp'));
246
-            $this->where_params['REG_date'] = [
247
-                'BETWEEN',
248
-                [
249
-                    $this->registration_model->convert_datetime_for_query(
250
-                        'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
252
-                        'Y-m-d H:i:s'
253
-                    ),
254
-                    $this->registration_model->convert_datetime_for_query(
255
-                        'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
-                        'Y-m-d H:i:s'
258
-                    ),
259
-                ],
260
-            ];
261
-            return;
262
-        }
263
-        $month_range = $this->request->getRequestParam('month_range');
264
-        if ($month_range) {
265
-            $month_range = sanitize_text_field($month_range);
266
-            $pieces = explode(' ', $month_range, 3);
267
-            $month_requested = ! empty($pieces[0])
268
-                ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
-                : '';
270
-            $year_requested = ! empty($pieces[1])
271
-                ? $pieces[1]
272
-                : '';
273
-            // if there is not a month or year then we can't go further
274
-            if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
-                $this->where_params['REG_date'] = [
277
-                    'BETWEEN',
278
-                    [
279
-                        $this->registration_model->convert_datetime_for_query(
280
-                            'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
282
-                            'Y-m-d H:i:s'
283
-                        ),
284
-                        $this->registration_model->convert_datetime_for_query(
285
-                            'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
-                            'Y-m-d H:i:s'
288
-                        ),
289
-                    ],
290
-                ];
291
-            }
292
-        }
293
-    }
294
-
295
-
296
-    /**
297
-     * Adds any provided search restraints to the where conditions for the registrations query
298
-     */
299
-    protected function addSearchToWhereConditions()
300
-    {
301
-        $search = $this->request->getRequestParam('s');
302
-        if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
304
-            $this->where_params['OR*search_conditions'] = [
305
-                'Event.EVT_name'                          => ['LIKE', $search_string],
306
-                'Event.EVT_desc'                          => ['LIKE', $search_string],
307
-                'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
-                'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
-                'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
-                'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
-                'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
-                'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
-                'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
-                'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
-                'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
-                'REG_final_price'                         => ['LIKE', $search_string],
317
-                'REG_code'                                => ['LIKE', $search_string],
318
-                'REG_count'                               => ['LIKE', $search_string],
319
-                'REG_group_size'                          => ['LIKE', $search_string],
320
-                'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
-                'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
-            ];
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * Sets up the orderby for the registrations query.
330
-     *
331
-     * @return array
332
-     */
333
-    protected function getOrderbyClause()
334
-    {
335
-        $orderby_field = $this->request->getRequestParam('orderby');
336
-        $orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
-        switch ($orderby_field) {
338
-            case '_REG_ID':
339
-                $orderby = ['REG_ID'];
340
-                break;
341
-            case '_Reg_status':
342
-                $orderby = ['STS_ID'];
343
-                break;
344
-            case 'ATT_fname':
345
-                $orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
-                break;
347
-            case 'ATT_lname':
348
-                $orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
-                break;
350
-            case 'event_name':
351
-                $orderby = ['Event.EVT_name'];
352
-                break;
353
-            case 'DTT_EVT_start':
354
-                $orderby = ['Event.Datetime.DTT_EVT_start'];
355
-                break;
356
-            case '_REG_date':
357
-                $orderby = ['REG_date'];
358
-                break;
359
-            default:
360
-                $orderby = [$orderby_field];
361
-                break;
362
-        }
363
-        $order = $this->request->getRequestParam('order');
364
-        $order = $order ? sanitize_text_field($order) : 'DESC';
365
-
366
-        $orderby = array_combine(
367
-            $orderby,
368
-            array_fill(0, count($orderby), $order)
369
-        );
370
-        // because there are many registrations with the same date, define
371
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
372
-        if (empty($orderby['REG_ID'])) {
373
-            $orderby['REG_ID'] = $order;
374
-        }
375
-
376
-        $orderby = apply_filters(
377
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
-            $orderby,
379
-            $this->request->requestParams()
380
-        );
381
-        return ['order_by' => $orderby];
382
-    }
383
-
384
-
385
-    /**
386
-     * Sets up the limit for the registrations query.
387
-     *
388
-     * @param $per_page
389
-     * @return array
390
-     */
391
-    protected function getLimitClause($per_page)
392
-    {
393
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
394
-        $per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
395
-        // -1 means return all results so get out if that's set.
396
-        if ($per_page === -1) {
397
-            return [];
398
-        }
399
-        $offset = ($current_page - 1) * $per_page;
400
-        return ['limit' => [$offset, $per_page]];
401
-    }
24
+	/**
25
+	 * @var RequestInterface $request
26
+	 */
27
+	protected $request;
28
+
29
+	/**
30
+	 * @var EEM_Registration $registration_model
31
+	 */
32
+	protected $registration_model;
33
+
34
+	/**
35
+	 * @var string $view
36
+	 */
37
+	protected $view;
38
+
39
+	/**
40
+	 * @var array $where_params
41
+	 */
42
+	protected $where_params;
43
+
44
+
45
+	/**
46
+	 * QueryBuilder constructor.
47
+	 *
48
+	 * @param RequestInterface $request
49
+	 * @param EEM_Registration $registration_model
50
+	 * @param array            $extra_request_params
51
+	 */
52
+	public function __construct(
53
+		RequestInterface $request,
54
+		EEM_Registration $registration_model,
55
+		array $extra_request_params = []
56
+	) {
57
+		$this->request = $request;
58
+		$this->registration_model = $registration_model;
59
+		foreach ($extra_request_params as $key => $value) {
60
+			$this->request->setRequestParam($key, $value);
61
+		}
62
+		$this->view = $this->request->getRequestParam('status', '');
63
+		$this->where_params = [];
64
+	}
65
+
66
+
67
+	/**
68
+	 * Sets up the where conditions for the registrations query.
69
+	 *
70
+	 * @param int  $per_page
71
+	 * @param bool $count_query
72
+	 * @return array
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 */
78
+	public function getQueryParams($per_page = 10, $count_query = false)
79
+	{
80
+		$query_params = [
81
+			0                          => $this->getWhereClause(),
82
+			'caps'                     => EEM_Registration::caps_read_admin,
83
+			'default_where_conditions' => 'this_model_only',
84
+		];
85
+		if (! $count_query) {
86
+			$query_params = array_merge(
87
+				$query_params,
88
+				$this->getOrderbyClause(),
89
+				$this->getLimitClause($per_page)
90
+			);
91
+		}
92
+
93
+		return $query_params;
94
+	}
95
+
96
+
97
+	/**
98
+	 * Sets up the where conditions for the registrations query.
99
+	 *
100
+	 * @return array
101
+	 * @throws EE_Error
102
+	 * @throws InvalidArgumentException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws InvalidInterfaceException
105
+	 */
106
+	protected function getWhereClause()
107
+	{
108
+		$this->addAttendeeIdToWhereConditions();
109
+		$this->addEventIdToWhereConditions();
110
+		$this->addCategoryIdToWhereConditions();
111
+		$this->addDatetimeIdToWhereConditions();
112
+		$this->addTicketIdToWhereConditions();
113
+		$this->addRegistrationStatusToWhereConditions();
114
+		$this->addDateToWhereConditions();
115
+		$this->addSearchToWhereConditions();
116
+		return apply_filters(
117
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
+			$this->where_params,
119
+			$this->request->requestParams()
120
+		);
121
+	}
122
+
123
+
124
+	/**
125
+	 * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
+	 */
127
+	protected function addAttendeeIdToWhereConditions()
128
+	{
129
+		$ATT_ID = $this->request->getRequestParam('attendee_id');
130
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID, 'int');
131
+		if ($ATT_ID) {
132
+			$this->where_params['ATT_ID'] = $ATT_ID;
133
+		}
134
+	}
135
+
136
+
137
+	/**
138
+	 * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
+	 */
140
+	protected function addEventIdToWhereConditions()
141
+	{
142
+		$EVT_ID = $this->request->getRequestParam('event_id');
143
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID, 'int');
144
+		if ($EVT_ID) {
145
+			$this->where_params['EVT_ID'] = $EVT_ID;
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
+	 */
153
+	protected function addCategoryIdToWhereConditions()
154
+	{
155
+		$EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT', 0, 'int');
156
+		if ($EVT_CAT > 0) {
157
+			$this->where_params['Event.Term_Taxonomy.term_id'] = $EVT_CAT;
158
+		}
159
+	}
160
+
161
+
162
+	/**
163
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
+	 */
165
+	protected function addDatetimeIdToWhereConditions()
166
+	{
167
+		// first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
+		$DTT_ID = $this->request->getRequestParam('datetime_id');
169
+		$DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID, 'int');
170
+		if ($DTT_ID) {
171
+			$this->where_params['Ticket.Datetime.DTT_ID'] = $DTT_ID;
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
+	 */
179
+	protected function addTicketIdToWhereConditions()
180
+	{
181
+		// first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
+		$TKT_ID = $this->request->getRequestParam('ticket_id');
183
+		$TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID, 'int');
184
+		if ($TKT_ID) {
185
+			$this->where_params['TKT_ID'] = $TKT_ID;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * Adds the correct registration status to the where conditions for the registrations query.
192
+	 * If filtering by registration status, then we show registrations matching that status.
193
+	 * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
+	 * UNLESS viewing trashed registrations.
195
+	 */
196
+	protected function addRegistrationStatusToWhereConditions()
197
+	{
198
+		$registration_status = $this->request->getRequestParam('_reg_status');
199
+		if ($registration_status) {
200
+			$this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
+			return;
202
+		}
203
+		// make sure we exclude incomplete registrations, but only if not trashed.
204
+		if ($this->view === 'trash') {
205
+			$this->where_params['REG_deleted'] = true;
206
+			return;
207
+		}
208
+		$this->where_params['STS_ID'] = $this->view === 'incomplete'
209
+			? EEM_Registration::status_id_incomplete
210
+			: ['!=', EEM_Registration::status_id_incomplete];
211
+	}
212
+
213
+
214
+	/**
215
+	 * Adds any provided date restraints to the where conditions for the registrations query.
216
+	 *
217
+	 * @throws EE_Error
218
+	 * @throws InvalidArgumentException
219
+	 * @throws InvalidDataTypeException
220
+	 * @throws InvalidInterfaceException
221
+	 */
222
+	protected function addDateToWhereConditions()
223
+	{
224
+		if ($this->view === 'today') {
225
+			$now = date('Y-m-d', current_time('timestamp'));
226
+			$this->where_params['REG_date'] = [
227
+				'BETWEEN',
228
+				[
229
+					$this->registration_model->convert_datetime_for_query(
230
+						'REG_date',
231
+						$now . ' 00:00:00',
232
+						'Y-m-d H:i:s'
233
+					),
234
+					$this->registration_model->convert_datetime_for_query(
235
+						'REG_date',
236
+						$now . ' 23:59:59',
237
+						'Y-m-d H:i:s'
238
+					),
239
+				],
240
+			];
241
+			return;
242
+		}
243
+		if ($this->view === 'month') {
244
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
245
+			$days_this_month = date('t', current_time('timestamp'));
246
+			$this->where_params['REG_date'] = [
247
+				'BETWEEN',
248
+				[
249
+					$this->registration_model->convert_datetime_for_query(
250
+						'REG_date',
251
+						$current_year_and_month . '-01 00:00:00',
252
+						'Y-m-d H:i:s'
253
+					),
254
+					$this->registration_model->convert_datetime_for_query(
255
+						'REG_date',
256
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
+						'Y-m-d H:i:s'
258
+					),
259
+				],
260
+			];
261
+			return;
262
+		}
263
+		$month_range = $this->request->getRequestParam('month_range');
264
+		if ($month_range) {
265
+			$month_range = sanitize_text_field($month_range);
266
+			$pieces = explode(' ', $month_range, 3);
267
+			$month_requested = ! empty($pieces[0])
268
+				? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
+				: '';
270
+			$year_requested = ! empty($pieces[1])
271
+				? $pieces[1]
272
+				: '';
273
+			// if there is not a month or year then we can't go further
274
+			if ($month_requested && $year_requested) {
275
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
+				$this->where_params['REG_date'] = [
277
+					'BETWEEN',
278
+					[
279
+						$this->registration_model->convert_datetime_for_query(
280
+							'REG_date',
281
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
282
+							'Y-m-d H:i:s'
283
+						),
284
+						$this->registration_model->convert_datetime_for_query(
285
+							'REG_date',
286
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
+							'Y-m-d H:i:s'
288
+						),
289
+					],
290
+				];
291
+			}
292
+		}
293
+	}
294
+
295
+
296
+	/**
297
+	 * Adds any provided search restraints to the where conditions for the registrations query
298
+	 */
299
+	protected function addSearchToWhereConditions()
300
+	{
301
+		$search = $this->request->getRequestParam('s');
302
+		if ($search) {
303
+			$search_string = '%' . sanitize_text_field($search) . '%';
304
+			$this->where_params['OR*search_conditions'] = [
305
+				'Event.EVT_name'                          => ['LIKE', $search_string],
306
+				'Event.EVT_desc'                          => ['LIKE', $search_string],
307
+				'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
+				'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
+				'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
+				'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
+				'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
+				'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
+				'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
+				'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
+				'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
+				'REG_final_price'                         => ['LIKE', $search_string],
317
+				'REG_code'                                => ['LIKE', $search_string],
318
+				'REG_count'                               => ['LIKE', $search_string],
319
+				'REG_group_size'                          => ['LIKE', $search_string],
320
+				'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
+				'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
+			];
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * Sets up the orderby for the registrations query.
330
+	 *
331
+	 * @return array
332
+	 */
333
+	protected function getOrderbyClause()
334
+	{
335
+		$orderby_field = $this->request->getRequestParam('orderby');
336
+		$orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
+		switch ($orderby_field) {
338
+			case '_REG_ID':
339
+				$orderby = ['REG_ID'];
340
+				break;
341
+			case '_Reg_status':
342
+				$orderby = ['STS_ID'];
343
+				break;
344
+			case 'ATT_fname':
345
+				$orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
+				break;
347
+			case 'ATT_lname':
348
+				$orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
+				break;
350
+			case 'event_name':
351
+				$orderby = ['Event.EVT_name'];
352
+				break;
353
+			case 'DTT_EVT_start':
354
+				$orderby = ['Event.Datetime.DTT_EVT_start'];
355
+				break;
356
+			case '_REG_date':
357
+				$orderby = ['REG_date'];
358
+				break;
359
+			default:
360
+				$orderby = [$orderby_field];
361
+				break;
362
+		}
363
+		$order = $this->request->getRequestParam('order');
364
+		$order = $order ? sanitize_text_field($order) : 'DESC';
365
+
366
+		$orderby = array_combine(
367
+			$orderby,
368
+			array_fill(0, count($orderby), $order)
369
+		);
370
+		// because there are many registrations with the same date, define
371
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
372
+		if (empty($orderby['REG_ID'])) {
373
+			$orderby['REG_ID'] = $order;
374
+		}
375
+
376
+		$orderby = apply_filters(
377
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
+			$orderby,
379
+			$this->request->requestParams()
380
+		);
381
+		return ['order_by' => $orderby];
382
+	}
383
+
384
+
385
+	/**
386
+	 * Sets up the limit for the registrations query.
387
+	 *
388
+	 * @param $per_page
389
+	 * @return array
390
+	 */
391
+	protected function getLimitClause($per_page)
392
+	{
393
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
394
+		$per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
395
+		// -1 means return all results so get out if that's set.
396
+		if ($per_page === -1) {
397
+			return [];
398
+		}
399
+		$offset = ($current_page - 1) * $per_page;
400
+		return ['limit' => [$offset, $per_page]];
401
+	}
402 402
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextFactory.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -17,128 +17,128 @@
 block discarded – undo
17 17
 class RequestTypeContextFactory implements RequestTypeContextFactoryInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    private $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	private $loader;
24 24
 
25 25
 
26
-    /**
27
-     * RequestTypeContextFactory constructor.
28
-     *
29
-     * @param LoaderInterface $loader
30
-     */
31
-    public function __construct(LoaderInterface $loader)
32
-    {
33
-        $this->loader = $loader;
34
-    }
26
+	/**
27
+	 * RequestTypeContextFactory constructor.
28
+	 *
29
+	 * @param LoaderInterface $loader
30
+	 */
31
+	public function __construct(LoaderInterface $loader)
32
+	{
33
+		$this->loader = $loader;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @param string $slug
39
-     * @return RequestTypeContext
40
-     */
41
-    public function create($slug)
42
-    {
43
-        switch ($slug) {
44
-            case RequestTypeContext::ACTIVATION:
45
-                $description = esc_html__(
46
-                    'The current request is for some form of activation',
47
-                    'event_espresso'
48
-                );
49
-                break;
50
-            case RequestTypeContext::API:
51
-                $description = esc_html__(
52
-                    'The current request is for the EE REST API',
53
-                    'event_espresso'
54
-                );
55
-                break;
56
-            case RequestTypeContext::AJAX_FRONT:
57
-                $description = esc_html__(
58
-                    'The current request is for the frontend via AJAX',
59
-                    'event_espresso'
60
-                );
61
-                break;
62
-            case RequestTypeContext::AJAX_ADMIN:
63
-                $description = esc_html__(
64
-                    'The current request is for the admin via AJAX',
65
-                    'event_espresso'
66
-                );
67
-                break;
68
-            case RequestTypeContext::AJAX_HEARTBEAT:
69
-                $description = esc_html__(
70
-                    'The current request is for the WP Heartbeat',
71
-                    'event_espresso'
72
-                );
73
-                break;
74
-            case RequestTypeContext::AJAX_OTHER:
75
-                $description = esc_html__(
76
-                    'The current request is for non-EE related code via AJAX',
77
-                    'event_espresso'
78
-                );
79
-                break;
80
-            case RequestTypeContext::CRON:
81
-                $description = esc_html__(
82
-                    'The current request is for a WP_Cron',
83
-                    'event_espresso'
84
-                );
85
-                break;
86
-            case RequestTypeContext::CLI:
87
-                $description = esc_html__(
88
-                    'The current request is from the command line',
89
-                    'event_espresso'
90
-                );
91
-                break;
92
-            case RequestTypeContext::ADMIN:
93
-                $description = esc_html__(
94
-                    'The current request is for the admin',
95
-                    'event_espresso'
96
-                );
97
-                break;
98
-            case RequestTypeContext::IFRAME:
99
-                $description = esc_html__(
100
-                    'The current request is for an iframe',
101
-                    'event_espresso'
102
-                );
103
-                break;
104
-            case RequestTypeContext::FEED:
105
-                $description = esc_html__(
106
-                    'The current request is for a feed (ie: RSS)',
107
-                    'event_espresso'
108
-                );
109
-                break;
110
-            case RequestTypeContext::GQL:
111
-                $description = esc_html__(
112
-                    'The current request is for the EE GraphQL Manager',
113
-                    'event_espresso'
114
-                );
115
-                break;
116
-            case RequestTypeContext::WP_API:
117
-                $description = esc_html__(
118
-                    'The current request is for the WordPress REST API',
119
-                    'event_espresso'
120
-                );
121
-                break;
122
-            case RequestTypeContext::WP_SCRAPE:
123
-                $description = esc_html__(
124
-                    'The current request is for a WordPress loopback scrape',
125
-                    'event_espresso'
126
-                );
127
-                break;
128
-            case RequestTypeContext::FRONTEND:
129
-            default:
130
-                $description = esc_html__(
131
-                    'The current request is for the frontend',
132
-                    'event_espresso'
133
-                );
134
-                break;
135
-        }
136
-        // we're using the Loader with sharing turned on,
137
-        // so that the generated RequestTypeContext object is accessible anywhere
138
-        // by simply requesting it again from the loader
139
-        return $this->loader->getShared(
140
-            'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
141
-            array($slug, $description)
142
-        );
143
-    }
37
+	/**
38
+	 * @param string $slug
39
+	 * @return RequestTypeContext
40
+	 */
41
+	public function create($slug)
42
+	{
43
+		switch ($slug) {
44
+			case RequestTypeContext::ACTIVATION:
45
+				$description = esc_html__(
46
+					'The current request is for some form of activation',
47
+					'event_espresso'
48
+				);
49
+				break;
50
+			case RequestTypeContext::API:
51
+				$description = esc_html__(
52
+					'The current request is for the EE REST API',
53
+					'event_espresso'
54
+				);
55
+				break;
56
+			case RequestTypeContext::AJAX_FRONT:
57
+				$description = esc_html__(
58
+					'The current request is for the frontend via AJAX',
59
+					'event_espresso'
60
+				);
61
+				break;
62
+			case RequestTypeContext::AJAX_ADMIN:
63
+				$description = esc_html__(
64
+					'The current request is for the admin via AJAX',
65
+					'event_espresso'
66
+				);
67
+				break;
68
+			case RequestTypeContext::AJAX_HEARTBEAT:
69
+				$description = esc_html__(
70
+					'The current request is for the WP Heartbeat',
71
+					'event_espresso'
72
+				);
73
+				break;
74
+			case RequestTypeContext::AJAX_OTHER:
75
+				$description = esc_html__(
76
+					'The current request is for non-EE related code via AJAX',
77
+					'event_espresso'
78
+				);
79
+				break;
80
+			case RequestTypeContext::CRON:
81
+				$description = esc_html__(
82
+					'The current request is for a WP_Cron',
83
+					'event_espresso'
84
+				);
85
+				break;
86
+			case RequestTypeContext::CLI:
87
+				$description = esc_html__(
88
+					'The current request is from the command line',
89
+					'event_espresso'
90
+				);
91
+				break;
92
+			case RequestTypeContext::ADMIN:
93
+				$description = esc_html__(
94
+					'The current request is for the admin',
95
+					'event_espresso'
96
+				);
97
+				break;
98
+			case RequestTypeContext::IFRAME:
99
+				$description = esc_html__(
100
+					'The current request is for an iframe',
101
+					'event_espresso'
102
+				);
103
+				break;
104
+			case RequestTypeContext::FEED:
105
+				$description = esc_html__(
106
+					'The current request is for a feed (ie: RSS)',
107
+					'event_espresso'
108
+				);
109
+				break;
110
+			case RequestTypeContext::GQL:
111
+				$description = esc_html__(
112
+					'The current request is for the EE GraphQL Manager',
113
+					'event_espresso'
114
+				);
115
+				break;
116
+			case RequestTypeContext::WP_API:
117
+				$description = esc_html__(
118
+					'The current request is for the WordPress REST API',
119
+					'event_espresso'
120
+				);
121
+				break;
122
+			case RequestTypeContext::WP_SCRAPE:
123
+				$description = esc_html__(
124
+					'The current request is for a WordPress loopback scrape',
125
+					'event_espresso'
126
+				);
127
+				break;
128
+			case RequestTypeContext::FRONTEND:
129
+			default:
130
+				$description = esc_html__(
131
+					'The current request is for the frontend',
132
+					'event_espresso'
133
+				);
134
+				break;
135
+		}
136
+		// we're using the Loader with sharing turned on,
137
+		// so that the generated RequestTypeContext object is accessible anywhere
138
+		// by simply requesting it again from the loader
139
+		return $this->loader->getShared(
140
+			'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
141
+			array($slug, $description)
142
+		);
143
+	}
144 144
 }
Please login to merge, or discard this patch.
core/domain/services/converters/json/DatetimeToJson.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $jsonDates = [];
38 38
         foreach ($datetimes as $datetime) {
39 39
             if ($datetime instanceof EE_Datetime) {
40
-                $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime);
40
+                $jsonDates[$datetime->ID()] = $this->convertAndEncode($datetime);
41 41
             }
42 42
         }
43 43
         return $jsonDates;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $arrayOfDates = [];
76 76
         foreach ($datetimes as $datetime) {
77 77
             if ($datetime instanceof EE_Datetime) {
78
-                $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime);
78
+                $arrayOfDates[$datetime->ID()] = $this->convert($datetime);
79 79
             }
80 80
         }
81 81
         return $arrayOfDates;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         $jsonDates = [];
128 128
         foreach ($datetimes as $datetime) {
129 129
             if ($datetime instanceof EE_Datetime) {
130
-                $jsonDates[ $datetime->ID() ] = $this->encode($datetime);
130
+                $jsonDates[$datetime->ID()] = $this->encode($datetime);
131 131
             }
132 132
         }
133 133
         return $jsonDates;
Please login to merge, or discard this patch.
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -22,125 +22,125 @@
 block discarded – undo
22 22
 class DatetimeToJson implements ModelObjectToJsonConverterInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @param EE_Datetime[] $datetimes
27
-     * @return array
28
-     * @throws EE_Error
29
-     * @throws InvalidArgumentException
30
-     * @throws InvalidDataTypeException
31
-     * @throws InvalidInterfaceException
32
-     * @throws ReflectionException
33
-     * @since $VID:$
34
-     */
35
-    public function convertAndEncodeArrayOf(array $datetimes)
36
-    {
37
-        $jsonDates = [];
38
-        foreach ($datetimes as $datetime) {
39
-            if ($datetime instanceof EE_Datetime) {
40
-                $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime);
41
-            }
42
-        }
43
-        return $jsonDates;
44
-    }
25
+	/**
26
+	 * @param EE_Datetime[] $datetimes
27
+	 * @return array
28
+	 * @throws EE_Error
29
+	 * @throws InvalidArgumentException
30
+	 * @throws InvalidDataTypeException
31
+	 * @throws InvalidInterfaceException
32
+	 * @throws ReflectionException
33
+	 * @since $VID:$
34
+	 */
35
+	public function convertAndEncodeArrayOf(array $datetimes)
36
+	{
37
+		$jsonDates = [];
38
+		foreach ($datetimes as $datetime) {
39
+			if ($datetime instanceof EE_Datetime) {
40
+				$jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime);
41
+			}
42
+		}
43
+		return $jsonDates;
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * @param EE_Datetime $datetime
49
-     * @return false|string
50
-     * @throws EE_Error
51
-     * @throws InvalidArgumentException
52
-     * @throws InvalidDataTypeException
53
-     * @throws InvalidInterfaceException
54
-     * @throws ReflectionException
55
-     * @since $VID:$
56
-     */
57
-    public function convertAndEncode($datetime)
58
-    {
59
-        return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false;
60
-    }
47
+	/**
48
+	 * @param EE_Datetime $datetime
49
+	 * @return false|string
50
+	 * @throws EE_Error
51
+	 * @throws InvalidArgumentException
52
+	 * @throws InvalidDataTypeException
53
+	 * @throws InvalidInterfaceException
54
+	 * @throws ReflectionException
55
+	 * @since $VID:$
56
+	 */
57
+	public function convertAndEncode($datetime)
58
+	{
59
+		return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @param EE_Datetime[] $datetimes
65
-     * @return array
66
-     * @throws EE_Error
67
-     * @throws InvalidArgumentException
68
-     * @throws InvalidDataTypeException
69
-     * @throws InvalidInterfaceException
70
-     * @throws ReflectionException
71
-     * @since $VID:$
72
-     */
73
-    public function convertArrayOf(array $datetimes)
74
-    {
75
-        $arrayOfDates = [];
76
-        foreach ($datetimes as $datetime) {
77
-            if ($datetime instanceof EE_Datetime) {
78
-                $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime);
79
-            }
80
-        }
81
-        return $arrayOfDates;
82
-    }
63
+	/**
64
+	 * @param EE_Datetime[] $datetimes
65
+	 * @return array
66
+	 * @throws EE_Error
67
+	 * @throws InvalidArgumentException
68
+	 * @throws InvalidDataTypeException
69
+	 * @throws InvalidInterfaceException
70
+	 * @throws ReflectionException
71
+	 * @since $VID:$
72
+	 */
73
+	public function convertArrayOf(array $datetimes)
74
+	{
75
+		$arrayOfDates = [];
76
+		foreach ($datetimes as $datetime) {
77
+			if ($datetime instanceof EE_Datetime) {
78
+				$arrayOfDates[ $datetime->ID() ] = $this->convert($datetime);
79
+			}
80
+		}
81
+		return $arrayOfDates;
82
+	}
83 83
 
84 84
 
85
-    /**
86
-     * @param EE_Datetime $datetime
87
-     * @return array
88
-     * @throws EE_Error
89
-     * @throws InvalidDataTypeException
90
-     * @throws InvalidInterfaceException
91
-     * @throws InvalidArgumentException
92
-     * @throws ReflectionException
93
-     * @since $VID:$
94
-     */
95
-    public function convert($datetime)
96
-    {
97
-        return $datetime instanceof EE_Datetime ? [
98
-            'DTT_ID'          => $datetime->ID(),
99
-            'EVT_ID'          => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0,
100
-            'DTT_name'        => $datetime->name(),
101
-            'DTT_description' => $datetime->description(),
102
-            'DTT_EVT_start'   => $datetime->start_date(DATE_ATOM),
103
-            'DTT_EVT_end'     => $datetime->end_date(DATE_ATOM),
104
-            'DTT_sold'        => $datetime->sold(),
105
-            'DTT_reserved'    => $datetime->reserved(),
106
-            'DTT_reg_limit'   => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(),
107
-            'DTT_is_primary'  => $datetime->get_active_status(),
108
-            'DTT_order'       => $datetime->order(),
109
-            'DTT_parent'      => $datetime->parent(),
110
-            'DTT_deleted'     => $datetime->get('DTT_deleted'),
111
-        ] : [];
112
-    }
85
+	/**
86
+	 * @param EE_Datetime $datetime
87
+	 * @return array
88
+	 * @throws EE_Error
89
+	 * @throws InvalidDataTypeException
90
+	 * @throws InvalidInterfaceException
91
+	 * @throws InvalidArgumentException
92
+	 * @throws ReflectionException
93
+	 * @since $VID:$
94
+	 */
95
+	public function convert($datetime)
96
+	{
97
+		return $datetime instanceof EE_Datetime ? [
98
+			'DTT_ID'          => $datetime->ID(),
99
+			'EVT_ID'          => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0,
100
+			'DTT_name'        => $datetime->name(),
101
+			'DTT_description' => $datetime->description(),
102
+			'DTT_EVT_start'   => $datetime->start_date(DATE_ATOM),
103
+			'DTT_EVT_end'     => $datetime->end_date(DATE_ATOM),
104
+			'DTT_sold'        => $datetime->sold(),
105
+			'DTT_reserved'    => $datetime->reserved(),
106
+			'DTT_reg_limit'   => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(),
107
+			'DTT_is_primary'  => $datetime->get_active_status(),
108
+			'DTT_order'       => $datetime->order(),
109
+			'DTT_parent'      => $datetime->parent(),
110
+			'DTT_deleted'     => $datetime->get('DTT_deleted'),
111
+		] : [];
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * @param EE_Datetime[] $datetimes
117
-     * @return array
118
-     * @throws EE_Error
119
-     * @throws InvalidArgumentException
120
-     * @throws InvalidDataTypeException
121
-     * @throws InvalidInterfaceException
122
-     * @throws ReflectionException
123
-     * @since $VID:$
124
-     */
125
-    public function encodeArrayOf(array $datetimes)
126
-    {
127
-        $jsonDates = [];
128
-        foreach ($datetimes as $datetime) {
129
-            if ($datetime instanceof EE_Datetime) {
130
-                $jsonDates[ $datetime->ID() ] = $this->encode($datetime);
131
-            }
132
-        }
133
-        return $jsonDates;
134
-    }
115
+	/**
116
+	 * @param EE_Datetime[] $datetimes
117
+	 * @return array
118
+	 * @throws EE_Error
119
+	 * @throws InvalidArgumentException
120
+	 * @throws InvalidDataTypeException
121
+	 * @throws InvalidInterfaceException
122
+	 * @throws ReflectionException
123
+	 * @since $VID:$
124
+	 */
125
+	public function encodeArrayOf(array $datetimes)
126
+	{
127
+		$jsonDates = [];
128
+		foreach ($datetimes as $datetime) {
129
+			if ($datetime instanceof EE_Datetime) {
130
+				$jsonDates[ $datetime->ID() ] = $this->encode($datetime);
131
+			}
132
+		}
133
+		return $jsonDates;
134
+	}
135 135
 
136 136
 
137
-    /**
138
-     * @param array $datetime_array
139
-     * @return false|string
140
-     * @since $VID:$
141
-     */
142
-    public function encode(array $datetime_array)
143
-    {
144
-        return wp_json_encode($datetime_array);
145
-    }
137
+	/**
138
+	 * @param array $datetime_array
139
+	 * @return false|string
140
+	 * @since $VID:$
141
+	 */
142
+	public function encode(array $datetime_array)
143
+	{
144
+		return wp_json_encode($datetime_array);
145
+	}
146 146
 }
Please login to merge, or discard this patch.
core/services/assets/AssetManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@
 block discarded – undo
176 176
         $version = ''
177 177
     ) {
178 178
         $dev_suffix = wp_scripts_get_suffix('dev');
179
-        $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
179
+        $vendor_path = $this->domain->pluginUrl().'assets/vendor/';
180 180
         return $this->addJavascript(
181 181
             $handle,
182 182
             "{$vendor_path}{$handle}{$dev_suffix}.js",
Please login to merge, or discard this patch.
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -23,332 +23,332 @@
 block discarded – undo
23 23
 abstract class AssetManager implements AssetManagerInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var AssetCollection|Asset[] $assets
28
-     */
29
-    protected $assets;
30
-
31
-    /**
32
-     * @var DomainInterface
33
-     */
34
-    protected $domain;
35
-
36
-    /**
37
-     * @var Registry $registry
38
-     */
39
-    protected $registry;
40
-
41
-
42
-    /**
43
-     * AssetRegister constructor.
44
-     *
45
-     * @param DomainInterface $domain
46
-     * @param AssetCollection $assets
47
-     * @param Registry        $registry
48
-     */
49
-    public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
50
-    {
51
-        $this->domain = $domain;
52
-        $this->assets = $assets;
53
-        $this->registry = $registry;
54
-        $this->registry->addAssetCollection($assets);
55
-        add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
56
-        add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return AssetCollection
62
-     */
63
-    public function getAssets()
64
-    {
65
-        return $this->assets;
66
-    }
67
-
68
-
69
-    /**
70
-     * @since 4.9.71.p
71
-     * @return string
72
-     */
73
-    public function assetNamespace()
74
-    {
75
-        return $this->domain->assetNamespace();
76
-    }
77
-
78
-
79
-    /**
80
-     * @param string $handle
81
-     * @param string $source
82
-     * @param array  $dependencies
83
-     * @param bool   $load_in_footer
84
-     * @param string $version
85
-     * @return JavascriptAsset
86
-     * @throws DuplicateCollectionIdentifierException
87
-     * @throws InvalidDataTypeException
88
-     * @throws InvalidEntityException
89
-     * @throws DomainException
90
-     * @since 4.9.62.p
91
-     */
92
-    public function addJavascript(
93
-        $handle,
94
-        $source,
95
-        array $dependencies = array(),
96
-        $load_in_footer = true,
97
-        $version = ''
98
-    ) {
99
-        $asset = new JavascriptAsset(
100
-            $handle,
101
-            $source,
102
-            array_unique($dependencies),
103
-            $load_in_footer,
104
-            $this->domain,
105
-            $version
106
-        );
107
-        $this->assets->add($asset, $handle);
108
-        return $asset;
109
-    }
110
-
111
-
112
-    /**
113
-     * Used to register a javascript asset where everything is dynamically derived from the given handle.
114
-     *
115
-     * @param string       $handle
116
-     * @param string|array $extra_dependencies
117
-     * @return JavascriptAsset
118
-     * @throws DuplicateCollectionIdentifierException
119
-     * @throws InvalidDataTypeException
120
-     * @throws InvalidEntityException
121
-     * @throws DomainException
122
-     */
123
-    public function addJs($handle, $extra_dependencies = [])
124
-    {
125
-        $details = $this->getAssetDetails(
126
-            Asset::TYPE_JS,
127
-            $handle,
128
-            $extra_dependencies
129
-        );
130
-        $source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle);
131
-        return $this->addJavascript(
132
-            $handle,
133
-            $source,
134
-            $details['dependencies'],
135
-            true,
136
-            $details['version']
137
-        );
138
-    }
139
-
140
-
141
-    /**
142
-     * @param string $handle
143
-     * @param array  $dependencies
144
-     * @param bool   $load_in_footer
145
-     * @param string $version
146
-     * @return JavascriptAsset
147
-     * @throws DomainException
148
-     * @throws DuplicateCollectionIdentifierException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     * @since 4.9.71.p
152
-     */
153
-    public function addVendorJavascript(
154
-        $handle,
155
-        array $dependencies = array(),
156
-        $load_in_footer = true,
157
-        $version = ''
158
-    ) {
159
-        $dev_suffix = wp_scripts_get_suffix('dev');
160
-        $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
161
-        return $this->addJavascript(
162
-            $handle,
163
-            "{$vendor_path}{$handle}{$dev_suffix}.js",
164
-            $dependencies,
165
-            $load_in_footer,
166
-            $version
167
-        );
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $handle
173
-     * @param string $source
174
-     * @param array  $dependencies
175
-     * @param string $media
176
-     * @param string $version
177
-     * @return StylesheetAsset
178
-     * @throws DomainException
179
-     * @throws DuplicateCollectionIdentifierException
180
-     * @throws InvalidDataTypeException
181
-     * @throws InvalidEntityException
182
-     * @since 4.9.62.p
183
-     */
184
-    public function addStylesheet(
185
-        $handle,
186
-        $source,
187
-        array $dependencies = array(),
188
-        $media = 'all',
189
-        $version = ''
190
-    ) {
191
-        $asset = new StylesheetAsset(
192
-            $handle,
193
-            $source,
194
-            array_unique($dependencies),
195
-            $this->domain,
196
-            $media,
197
-            $version
198
-        );
199
-        $this->assets->add($asset, $handle);
200
-        return $asset;
201
-    }
202
-
203
-
204
-    /**
205
-     * Used to register a css asset where everything is dynamically derived from the given handle.
206
-     *
207
-     * @param string       $handle
208
-     * @param string|array $extra_dependencies
209
-     * @return StylesheetAsset
210
-     * @throws DuplicateCollectionIdentifierException
211
-     * @throws InvalidDataTypeException
212
-     * @throws InvalidEntityException
213
-     * @throws DomainException
214
-     */
215
-    public function addCss($handle, $extra_dependencies = [])
216
-    {
217
-        $details = $this->getAssetDetails(
218
-            Asset::TYPE_CSS,
219
-            $handle,
220
-            $extra_dependencies
221
-        );
222
-        return $this->addStylesheet(
223
-            $handle,
224
-            $this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
225
-            $details['dependencies'],
226
-            'all',
227
-            $details['version']
228
-        );
229
-    }
230
-
231
-
232
-    /**
233
-     * @param string $handle
234
-     * @return bool
235
-     * @since 4.9.62.p
236
-     */
237
-    public function enqueueAsset($handle)
238
-    {
239
-        if ($this->assets->has($handle)) {
240
-            /** @var Asset $asset */
241
-            $asset = $this->assets->get($handle);
242
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
243
-                $asset->enqueueAsset();
244
-                return true;
245
-            }
246
-        }
247
-        return false;
248
-    }
249
-
250
-
251
-    /**
252
-     * @return  void
253
-     * @since   $VID:$
254
-     */
255
-    public function enqueueBrowserAssets()
256
-    {
257
-        foreach ($this->assets as $asset) {
258
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
259
-                $asset->enqueueAsset();
260
-            }
261
-        }
262
-    }
263
-
264
-
265
-    /**
266
-     * @param string $asset_type
267
-     * @param string $handle
268
-     * @param array  $extra_dependencies
269
-     * @return array
270
-     * @since 4.10.2.p
271
-     */
272
-    private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
273
-    {
274
-        $getAssetDetails = '';
275
-        switch ($asset_type) {
276
-            case Asset::TYPE_JS :
277
-                $getAssetDetails = 'getJsAssetDetails';
278
-                break;
279
-            case Asset::TYPE_CSS :
280
-                $getAssetDetails = 'getCssAssetDetails';
281
-                break;
282
-        }
283
-        if ($getAssetDetails === '') {
284
-            return ['dependencies' => [], 'version' => ''];
285
-        }
286
-        $details = $this->registry->$getAssetDetails(
287
-            $this->domain->assetNamespace(),
288
-            $handle
289
-        );
290
-        $details['dependencies'] = isset($details['dependencies'])
291
-            ? $details['dependencies']
292
-            : [];
293
-        $details['version'] = isset($details['version'])
294
-            ? $details['version']
295
-            : '';
296
-        $details['dependencies'] = ! empty($extra_dependencies)
297
-            ? array_merge($details['dependencies'], (array) $extra_dependencies)
298
-            : $details['dependencies'];
299
-        return $details;
300
-
301
-    }
302
-
303
-
304
-    /**
305
-     * @param string $handle
306
-     * @return bool
307
-     * @throws DomainException
308
-     */
309
-    public function verifyAssetIsRegistered($handle)
310
-    {
311
-        if (wp_script_is($handle, 'registered')) {
312
-            return true;
313
-        }
314
-        if (WP_DEBUG) {
315
-            throw new DomainException(
316
-                sprintf(
317
-                    esc_html__(
318
-                        'The "%1$s" script is not registered when it should be!%2$s
26
+	/**
27
+	 * @var AssetCollection|Asset[] $assets
28
+	 */
29
+	protected $assets;
30
+
31
+	/**
32
+	 * @var DomainInterface
33
+	 */
34
+	protected $domain;
35
+
36
+	/**
37
+	 * @var Registry $registry
38
+	 */
39
+	protected $registry;
40
+
41
+
42
+	/**
43
+	 * AssetRegister constructor.
44
+	 *
45
+	 * @param DomainInterface $domain
46
+	 * @param AssetCollection $assets
47
+	 * @param Registry        $registry
48
+	 */
49
+	public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
50
+	{
51
+		$this->domain = $domain;
52
+		$this->assets = $assets;
53
+		$this->registry = $registry;
54
+		$this->registry->addAssetCollection($assets);
55
+		add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
56
+		add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return AssetCollection
62
+	 */
63
+	public function getAssets()
64
+	{
65
+		return $this->assets;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @since 4.9.71.p
71
+	 * @return string
72
+	 */
73
+	public function assetNamespace()
74
+	{
75
+		return $this->domain->assetNamespace();
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param string $handle
81
+	 * @param string $source
82
+	 * @param array  $dependencies
83
+	 * @param bool   $load_in_footer
84
+	 * @param string $version
85
+	 * @return JavascriptAsset
86
+	 * @throws DuplicateCollectionIdentifierException
87
+	 * @throws InvalidDataTypeException
88
+	 * @throws InvalidEntityException
89
+	 * @throws DomainException
90
+	 * @since 4.9.62.p
91
+	 */
92
+	public function addJavascript(
93
+		$handle,
94
+		$source,
95
+		array $dependencies = array(),
96
+		$load_in_footer = true,
97
+		$version = ''
98
+	) {
99
+		$asset = new JavascriptAsset(
100
+			$handle,
101
+			$source,
102
+			array_unique($dependencies),
103
+			$load_in_footer,
104
+			$this->domain,
105
+			$version
106
+		);
107
+		$this->assets->add($asset, $handle);
108
+		return $asset;
109
+	}
110
+
111
+
112
+	/**
113
+	 * Used to register a javascript asset where everything is dynamically derived from the given handle.
114
+	 *
115
+	 * @param string       $handle
116
+	 * @param string|array $extra_dependencies
117
+	 * @return JavascriptAsset
118
+	 * @throws DuplicateCollectionIdentifierException
119
+	 * @throws InvalidDataTypeException
120
+	 * @throws InvalidEntityException
121
+	 * @throws DomainException
122
+	 */
123
+	public function addJs($handle, $extra_dependencies = [])
124
+	{
125
+		$details = $this->getAssetDetails(
126
+			Asset::TYPE_JS,
127
+			$handle,
128
+			$extra_dependencies
129
+		);
130
+		$source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle);
131
+		return $this->addJavascript(
132
+			$handle,
133
+			$source,
134
+			$details['dependencies'],
135
+			true,
136
+			$details['version']
137
+		);
138
+	}
139
+
140
+
141
+	/**
142
+	 * @param string $handle
143
+	 * @param array  $dependencies
144
+	 * @param bool   $load_in_footer
145
+	 * @param string $version
146
+	 * @return JavascriptAsset
147
+	 * @throws DomainException
148
+	 * @throws DuplicateCollectionIdentifierException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 * @since 4.9.71.p
152
+	 */
153
+	public function addVendorJavascript(
154
+		$handle,
155
+		array $dependencies = array(),
156
+		$load_in_footer = true,
157
+		$version = ''
158
+	) {
159
+		$dev_suffix = wp_scripts_get_suffix('dev');
160
+		$vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
161
+		return $this->addJavascript(
162
+			$handle,
163
+			"{$vendor_path}{$handle}{$dev_suffix}.js",
164
+			$dependencies,
165
+			$load_in_footer,
166
+			$version
167
+		);
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $handle
173
+	 * @param string $source
174
+	 * @param array  $dependencies
175
+	 * @param string $media
176
+	 * @param string $version
177
+	 * @return StylesheetAsset
178
+	 * @throws DomainException
179
+	 * @throws DuplicateCollectionIdentifierException
180
+	 * @throws InvalidDataTypeException
181
+	 * @throws InvalidEntityException
182
+	 * @since 4.9.62.p
183
+	 */
184
+	public function addStylesheet(
185
+		$handle,
186
+		$source,
187
+		array $dependencies = array(),
188
+		$media = 'all',
189
+		$version = ''
190
+	) {
191
+		$asset = new StylesheetAsset(
192
+			$handle,
193
+			$source,
194
+			array_unique($dependencies),
195
+			$this->domain,
196
+			$media,
197
+			$version
198
+		);
199
+		$this->assets->add($asset, $handle);
200
+		return $asset;
201
+	}
202
+
203
+
204
+	/**
205
+	 * Used to register a css asset where everything is dynamically derived from the given handle.
206
+	 *
207
+	 * @param string       $handle
208
+	 * @param string|array $extra_dependencies
209
+	 * @return StylesheetAsset
210
+	 * @throws DuplicateCollectionIdentifierException
211
+	 * @throws InvalidDataTypeException
212
+	 * @throws InvalidEntityException
213
+	 * @throws DomainException
214
+	 */
215
+	public function addCss($handle, $extra_dependencies = [])
216
+	{
217
+		$details = $this->getAssetDetails(
218
+			Asset::TYPE_CSS,
219
+			$handle,
220
+			$extra_dependencies
221
+		);
222
+		return $this->addStylesheet(
223
+			$handle,
224
+			$this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
225
+			$details['dependencies'],
226
+			'all',
227
+			$details['version']
228
+		);
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param string $handle
234
+	 * @return bool
235
+	 * @since 4.9.62.p
236
+	 */
237
+	public function enqueueAsset($handle)
238
+	{
239
+		if ($this->assets->has($handle)) {
240
+			/** @var Asset $asset */
241
+			$asset = $this->assets->get($handle);
242
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
243
+				$asset->enqueueAsset();
244
+				return true;
245
+			}
246
+		}
247
+		return false;
248
+	}
249
+
250
+
251
+	/**
252
+	 * @return  void
253
+	 * @since   $VID:$
254
+	 */
255
+	public function enqueueBrowserAssets()
256
+	{
257
+		foreach ($this->assets as $asset) {
258
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
259
+				$asset->enqueueAsset();
260
+			}
261
+		}
262
+	}
263
+
264
+
265
+	/**
266
+	 * @param string $asset_type
267
+	 * @param string $handle
268
+	 * @param array  $extra_dependencies
269
+	 * @return array
270
+	 * @since 4.10.2.p
271
+	 */
272
+	private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
273
+	{
274
+		$getAssetDetails = '';
275
+		switch ($asset_type) {
276
+			case Asset::TYPE_JS :
277
+				$getAssetDetails = 'getJsAssetDetails';
278
+				break;
279
+			case Asset::TYPE_CSS :
280
+				$getAssetDetails = 'getCssAssetDetails';
281
+				break;
282
+		}
283
+		if ($getAssetDetails === '') {
284
+			return ['dependencies' => [], 'version' => ''];
285
+		}
286
+		$details = $this->registry->$getAssetDetails(
287
+			$this->domain->assetNamespace(),
288
+			$handle
289
+		);
290
+		$details['dependencies'] = isset($details['dependencies'])
291
+			? $details['dependencies']
292
+			: [];
293
+		$details['version'] = isset($details['version'])
294
+			? $details['version']
295
+			: '';
296
+		$details['dependencies'] = ! empty($extra_dependencies)
297
+			? array_merge($details['dependencies'], (array) $extra_dependencies)
298
+			: $details['dependencies'];
299
+		return $details;
300
+
301
+	}
302
+
303
+
304
+	/**
305
+	 * @param string $handle
306
+	 * @return bool
307
+	 * @throws DomainException
308
+	 */
309
+	public function verifyAssetIsRegistered($handle)
310
+	{
311
+		if (wp_script_is($handle, 'registered')) {
312
+			return true;
313
+		}
314
+		if (WP_DEBUG) {
315
+			throw new DomainException(
316
+				sprintf(
317
+					esc_html__(
318
+						'The "%1$s" script is not registered when it should be!%2$s
319 319
                         Are you running the Barista plugin for development purposes? 
320 320
                         If so, then you need to build the appropriate assets for this domain.%2$s
321 321
                         If you are seeing this error on a live website, then you should not have 
322 322
                         the WP_DEBUG constant in your wp-config.php file set to "true". 
323 323
                         Please contact Event Espresso support for more information.',
324
-                        'event_espresso'
325
-                    ),
326
-                    $handle,
327
-                    '<br />'
328
-                )
329
-            );
330
-        }
331
-        return false;
332
-    }
333
-
334
-
335
-    /**************** deprecated ****************/
336
-
337
-
338
-    /**
339
-     * @return void
340
-     * @deprecated $VID:$
341
-     */
342
-    public function addManifestFile()
343
-    {
344
-    }
345
-
346
-
347
-    /**
348
-     * @return void
349
-     * @deprecated $VID:$
350
-     */
351
-    public function getManifestFile()
352
-    {
353
-    }
324
+						'event_espresso'
325
+					),
326
+					$handle,
327
+					'<br />'
328
+				)
329
+			);
330
+		}
331
+		return false;
332
+	}
333
+
334
+
335
+	/**************** deprecated ****************/
336
+
337
+
338
+	/**
339
+	 * @return void
340
+	 * @deprecated $VID:$
341
+	 */
342
+	public function addManifestFile()
343
+	{
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return void
349
+	 * @deprecated $VID:$
350
+	 */
351
+	public function getManifestFile()
352
+	{
353
+	}
354 354
 }
Please login to merge, or discard this patch.
services/admin/events/default_settings/AdvancedEditorAdminFormSection.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -39,86 +39,86 @@
 block discarded – undo
39 39
 class AdvancedEditorAdminFormSection
40 40
 {
41 41
 
42
-    /**
43
-     * @var EE_Admin_Config
44
-     */
45
-    protected $admin_config;
42
+	/**
43
+	 * @var EE_Admin_Config
44
+	 */
45
+	protected $admin_config;
46 46
 
47 47
 
48
-    /**
49
-     * AdvancedEditorAdminForm constructor.
50
-     *
51
-     * @param EE_Admin_Config $admin_config
52
-     */
53
-    public function __construct(EE_Admin_Config $admin_config)
54
-    {
55
-        $this->admin_config = $admin_config;
56
-        add_filter(
57
-            'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
58
-            [$this, 'mergeFormSubsections']
59
-        );
60
-        add_action(
61
-            'AHEE__Events_Admin_Page___update_default_event_settings',
62
-            [$this, 'updateAdminFormSettings'],
63
-            10,
64
-            2
65
-        );
66
-    }
48
+	/**
49
+	 * AdvancedEditorAdminForm constructor.
50
+	 *
51
+	 * @param EE_Admin_Config $admin_config
52
+	 */
53
+	public function __construct(EE_Admin_Config $admin_config)
54
+	{
55
+		$this->admin_config = $admin_config;
56
+		add_filter(
57
+			'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
58
+			[$this, 'mergeFormSubsections']
59
+		);
60
+		add_action(
61
+			'AHEE__Events_Admin_Page___update_default_event_settings',
62
+			[$this, 'updateAdminFormSettings'],
63
+			10,
64
+			2
65
+		);
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * @param array $default_event_settings_form_subsections
71
-     * @return array
72
-     * @since $VID:$
73
-     */
74
-    public function mergeFormSubsections(array $default_event_settings_form_subsections)
75
-    {
76
-        return [
77
-                   'use_advanced_editor'     => new EE_Select_Input(
78
-                       apply_filters(
79
-                           'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_answer_options',
80
-                           [
81
-                               esc_html__('Legacy Editor', 'event_espresso'),
82
-                               esc_html__('Advanced Editor', 'event_espresso'),
83
-                           ]
84
-                       ),
85
-                       apply_filters(
86
-                           'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_settings',
87
-                           [
88
-                               'default'         => $this->admin_config->useAdvancedEditor(),
89
-                               'html_label_text' => esc_html__('Activate Advanced Editor?', 'event_espresso'),
90
-                               'html_help_text'  => sprintf(
91
-                                   esc_html__(
92
-                                       'Controls whether the Event Espresso Event Editor continues to use the existing legacy editor that functions like the typical older WordPress admin you are used to,%1$sor uses the new Advanced Editor with a more powerful and easier to use interface. This may be automatically turned on in order to utilize advanced features from new addons.',
93
-                                       'event_espresso'
94
-                                   ),
95
-                                   '<br />'
96
-                               ),
97
-                           ]
98
-                       )
99
-                   ),
100
-                   'defaults_section_header' => new EE_Form_Section_HTML(
101
-                       EEH_HTML::h2(
102
-                           esc_html__('Default Settings', 'event_espresso'),
103
-                           '',
104
-                           'ee-admin-settings-hdr'
105
-                       )
106
-                   ),
107
-               ] + $default_event_settings_form_subsections;
108
-    }
69
+	/**
70
+	 * @param array $default_event_settings_form_subsections
71
+	 * @return array
72
+	 * @since $VID:$
73
+	 */
74
+	public function mergeFormSubsections(array $default_event_settings_form_subsections)
75
+	{
76
+		return [
77
+				   'use_advanced_editor'     => new EE_Select_Input(
78
+					   apply_filters(
79
+						   'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_answer_options',
80
+						   [
81
+							   esc_html__('Legacy Editor', 'event_espresso'),
82
+							   esc_html__('Advanced Editor', 'event_espresso'),
83
+						   ]
84
+					   ),
85
+					   apply_filters(
86
+						   'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_settings',
87
+						   [
88
+							   'default'         => $this->admin_config->useAdvancedEditor(),
89
+							   'html_label_text' => esc_html__('Activate Advanced Editor?', 'event_espresso'),
90
+							   'html_help_text'  => sprintf(
91
+								   esc_html__(
92
+									   'Controls whether the Event Espresso Event Editor continues to use the existing legacy editor that functions like the typical older WordPress admin you are used to,%1$sor uses the new Advanced Editor with a more powerful and easier to use interface. This may be automatically turned on in order to utilize advanced features from new addons.',
93
+									   'event_espresso'
94
+								   ),
95
+								   '<br />'
96
+							   ),
97
+						   ]
98
+					   )
99
+				   ),
100
+				   'defaults_section_header' => new EE_Form_Section_HTML(
101
+					   EEH_HTML::h2(
102
+						   esc_html__('Default Settings', 'event_espresso'),
103
+						   '',
104
+						   'ee-admin-settings-hdr'
105
+					   )
106
+				   ),
107
+			   ] + $default_event_settings_form_subsections;
108
+	}
109 109
 
110 110
 
111
-    /**
112
-     * @param array     $valid_data
113
-     * @param EE_Config $config
114
-     * @since $VID:$
115
-     */
116
-    public function updateAdminFormSettings(array $valid_data, EE_Config $config)
117
-    {
118
-        $config->admin->setUseAdvancedEditor(
119
-            isset($valid_data['use_advanced_editor'])
120
-                ? $valid_data['use_advanced_editor']
121
-                : false
122
-        );
123
-    }
111
+	/**
112
+	 * @param array     $valid_data
113
+	 * @param EE_Config $config
114
+	 * @since $VID:$
115
+	 */
116
+	public function updateAdminFormSettings(array $valid_data, EE_Config $config)
117
+	{
118
+		$config->admin->setUseAdvancedEditor(
119
+			isset($valid_data['use_advanced_editor'])
120
+				? $valid_data['use_advanced_editor']
121
+				: false
122
+		);
123
+	}
124 124
 }
Please login to merge, or discard this patch.
core/services/graphql/fields/GraphQLField.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     public function shouldResolve()
136 136
     {
137 137
         foreach ($this->caps as $cap) {
138
-            if (! current_user_can($cap)) {
138
+            if ( ! current_user_can($cap)) {
139 139
                 return false;
140 140
             }
141 141
         }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
168 168
     {
169
-        if (! $this->hasInternalResolver()) {
169
+        if ( ! $this->hasInternalResolver()) {
170 170
             throw new LogicException('GraphQLField has no internal resolver.');
171 171
         }
172 172
         // dynamic methods using $this don't play nice
Please login to merge, or discard this patch.
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -20,262 +20,262 @@
 block discarded – undo
20 20
 class GraphQLField implements GraphQLFieldInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var string $name
25
-     */
26
-    protected $name;
27
-
28
-    /**
29
-     * @var string|string[] $type
30
-     */
31
-    protected $type;
32
-
33
-    /**
34
-     * @var string|null $key
35
-     */
36
-    protected $key;
37
-
38
-    /**
39
-     * @var string $description
40
-     */
41
-    protected $description;
42
-
43
-    /**
44
-     * @var callable $formatter
45
-     */
46
-    protected $formatter;
47
-
48
-    /**
49
-     * @var callable $resolve
50
-     */
51
-    protected $resolver;
52
-
53
-    /**
54
-     * @var array $caps
55
-     */
56
-    protected $caps;
57
-
58
-    /**
59
-     * @var array $args
60
-     */
61
-    protected $args;
62
-
63
-    /**
64
-     * @var bool $use_for_input
65
-     */
66
-    protected $use_for_input = true;
67
-
68
-    /**
69
-     * @var bool $use_for_output
70
-     */
71
-    protected $use_for_output = true;
72
-
73
-
74
-    /**
75
-     * @param string          $name
76
-     * @param string|string[] $type
77
-     * @param string|null     $key
78
-     * @param string          $description
79
-     * @param callable|null   $formatter
80
-     * @param callable|null   $resolver
81
-     * @param array           $args
82
-     * @param array           $caps
83
-     * @param array           $args
84
-     */
85
-    public function __construct(
86
-        $name,
87
-        $type,
88
-        $key = null,
89
-        $description = '',
90
-        callable $formatter = null,
91
-        callable $resolver = null,
92
-        array $caps = [],
93
-        array $args = []
94
-    ) {
95
-        $this->name = $name;
96
-        $this->type = $type;
97
-        $this->key = $key;
98
-        $this->description = $description;
99
-        $this->formatter = $formatter;
100
-        $this->resolver = $resolver;
101
-        $this->caps = $caps;
102
-        $this->args = $args;
103
-    }
104
-
105
-
106
-    /**
107
-     * @return array
108
-     */
109
-    public function caps()
110
-    {
111
-        return $this->caps;
112
-    }
113
-
114
-
115
-    /**
116
-     * @return string
117
-     */
118
-    public function description()
119
-    {
120
-        return $this->description;
121
-    }
122
-
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function key()
128
-    {
129
-        return $this->key;
130
-    }
131
-
132
-
133
-    /**
134
-     * @return string
135
-     */
136
-    public function name()
137
-    {
138
-        return $this->name;
139
-    }
140
-
141
-
142
-    /**
143
-     * @return string|string[]
144
-     */
145
-    public function type()
146
-    {
147
-        return $this->type;
148
-    }
149
-
150
-
151
-    /**
152
-     * Convert the field to array to be
153
-     * able to pass as config to WP GraphQL
154
-     *
155
-     * @return array
156
-     */
157
-    public function toArray()
158
-    {
159
-        return get_object_vars($this);
160
-    }
161
-
162
-
163
-    /**
164
-     * Sets the value for use_for_input.
165
-     *
166
-     * @param bool $use_for_input
167
-     */
168
-    protected function setUseForInput($use_for_input)
169
-    {
170
-        $this->use_for_input = filter_var($use_for_input, FILTER_VALIDATE_BOOLEAN);
171
-    }
172
-
173
-
174
-    /**
175
-     * Whether the field should be used for
176
-     * mutation inputs.
177
-     *
178
-     * @return bool
179
-     */
180
-    public function useForInput()
181
-    {
182
-        return (bool) $this->use_for_input;
183
-    }
184
-
185
-
186
-    /**
187
-     * Whether the field should be used for
188
-     * query outputs.
189
-     *
190
-     * @return bool
191
-     */
192
-    public function useForOutput()
193
-    {
194
-        return (bool) $this->use_for_output;
195
-    }
196
-
197
-
198
-    /**
199
-     * Sets the value for use_for_output
200
-     *
201
-     * @param bool $use_for_output
202
-     */
203
-    protected function setUseForOutput($use_for_output)
204
-    {
205
-        $this->use_for_output = filter_var($use_for_output, FILTER_VALIDATE_BOOLEAN);
206
-    }
207
-
208
-
209
-    /**
210
-     * Whether the field should resolve
211
-     * based on the user caps etc.
212
-     *
213
-     * @return boolean
214
-     */
215
-    public function shouldResolve()
216
-    {
217
-        foreach ($this->caps as $cap) {
218
-            if (! current_user_can($cap)) {
219
-                return false;
220
-            }
221
-        }
222
-        return true;
223
-    }
224
-
225
-
226
-    /**
227
-     * Whether the field has an explicit resolver set.
228
-     *
229
-     * @return boolean
230
-     */
231
-    public function hasInternalResolver()
232
-    {
233
-        return is_callable($this->resolver);
234
-    }
235
-
236
-
237
-    /**
238
-     * Whether the field has an explicit resolver set.
239
-     *
240
-     * @param mixed       $source  The source that's passed down the GraphQL queries
241
-     * @param array       $args    The inputArgs on the field
242
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
243
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
244
-     * @return mixed
245
-     * @throws LogicException
246
-     */
247
-    public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
248
-    {
249
-        if (! $this->hasInternalResolver()) {
250
-            throw new LogicException('GraphQLField has no internal resolver.');
251
-        }
252
-        // dynamic methods using $this don't play nice
253
-        // so capture resolver to a single var first
254
-        $resolver = $this->resolver;
255
-        return $resolver($source, $args, $context, $info);
256
-    }
257
-
258
-
259
-    /**
260
-     * Checks if the format callback is set.
261
-     * If yes, then uses it to format the value.
262
-     *
263
-     * @param mixed         $value
264
-     * @param EE_Base_Class $source
265
-     * @return mixed The formatted value.
266
-     * @throws InvalidDataTypeException
267
-     * @throws InvalidInterfaceException
268
-     * @throws InvalidArgumentException
269
-     * @throws ReflectionException
270
-     */
271
-    public function mayBeFormatValue($value, EE_Base_Class $source)
272
-    {
273
-        if (is_callable($this->formatter)) {
274
-            // dynamic methods using $this don't play nice
275
-            // so capture formatter to a single var first
276
-            $formatter = $this->formatter;
277
-            return $formatter($value, $source);
278
-        }
279
-        return $value;
280
-    }
23
+	/**
24
+	 * @var string $name
25
+	 */
26
+	protected $name;
27
+
28
+	/**
29
+	 * @var string|string[] $type
30
+	 */
31
+	protected $type;
32
+
33
+	/**
34
+	 * @var string|null $key
35
+	 */
36
+	protected $key;
37
+
38
+	/**
39
+	 * @var string $description
40
+	 */
41
+	protected $description;
42
+
43
+	/**
44
+	 * @var callable $formatter
45
+	 */
46
+	protected $formatter;
47
+
48
+	/**
49
+	 * @var callable $resolve
50
+	 */
51
+	protected $resolver;
52
+
53
+	/**
54
+	 * @var array $caps
55
+	 */
56
+	protected $caps;
57
+
58
+	/**
59
+	 * @var array $args
60
+	 */
61
+	protected $args;
62
+
63
+	/**
64
+	 * @var bool $use_for_input
65
+	 */
66
+	protected $use_for_input = true;
67
+
68
+	/**
69
+	 * @var bool $use_for_output
70
+	 */
71
+	protected $use_for_output = true;
72
+
73
+
74
+	/**
75
+	 * @param string          $name
76
+	 * @param string|string[] $type
77
+	 * @param string|null     $key
78
+	 * @param string          $description
79
+	 * @param callable|null   $formatter
80
+	 * @param callable|null   $resolver
81
+	 * @param array           $args
82
+	 * @param array           $caps
83
+	 * @param array           $args
84
+	 */
85
+	public function __construct(
86
+		$name,
87
+		$type,
88
+		$key = null,
89
+		$description = '',
90
+		callable $formatter = null,
91
+		callable $resolver = null,
92
+		array $caps = [],
93
+		array $args = []
94
+	) {
95
+		$this->name = $name;
96
+		$this->type = $type;
97
+		$this->key = $key;
98
+		$this->description = $description;
99
+		$this->formatter = $formatter;
100
+		$this->resolver = $resolver;
101
+		$this->caps = $caps;
102
+		$this->args = $args;
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function caps()
110
+	{
111
+		return $this->caps;
112
+	}
113
+
114
+
115
+	/**
116
+	 * @return string
117
+	 */
118
+	public function description()
119
+	{
120
+		return $this->description;
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function key()
128
+	{
129
+		return $this->key;
130
+	}
131
+
132
+
133
+	/**
134
+	 * @return string
135
+	 */
136
+	public function name()
137
+	{
138
+		return $this->name;
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return string|string[]
144
+	 */
145
+	public function type()
146
+	{
147
+		return $this->type;
148
+	}
149
+
150
+
151
+	/**
152
+	 * Convert the field to array to be
153
+	 * able to pass as config to WP GraphQL
154
+	 *
155
+	 * @return array
156
+	 */
157
+	public function toArray()
158
+	{
159
+		return get_object_vars($this);
160
+	}
161
+
162
+
163
+	/**
164
+	 * Sets the value for use_for_input.
165
+	 *
166
+	 * @param bool $use_for_input
167
+	 */
168
+	protected function setUseForInput($use_for_input)
169
+	{
170
+		$this->use_for_input = filter_var($use_for_input, FILTER_VALIDATE_BOOLEAN);
171
+	}
172
+
173
+
174
+	/**
175
+	 * Whether the field should be used for
176
+	 * mutation inputs.
177
+	 *
178
+	 * @return bool
179
+	 */
180
+	public function useForInput()
181
+	{
182
+		return (bool) $this->use_for_input;
183
+	}
184
+
185
+
186
+	/**
187
+	 * Whether the field should be used for
188
+	 * query outputs.
189
+	 *
190
+	 * @return bool
191
+	 */
192
+	public function useForOutput()
193
+	{
194
+		return (bool) $this->use_for_output;
195
+	}
196
+
197
+
198
+	/**
199
+	 * Sets the value for use_for_output
200
+	 *
201
+	 * @param bool $use_for_output
202
+	 */
203
+	protected function setUseForOutput($use_for_output)
204
+	{
205
+		$this->use_for_output = filter_var($use_for_output, FILTER_VALIDATE_BOOLEAN);
206
+	}
207
+
208
+
209
+	/**
210
+	 * Whether the field should resolve
211
+	 * based on the user caps etc.
212
+	 *
213
+	 * @return boolean
214
+	 */
215
+	public function shouldResolve()
216
+	{
217
+		foreach ($this->caps as $cap) {
218
+			if (! current_user_can($cap)) {
219
+				return false;
220
+			}
221
+		}
222
+		return true;
223
+	}
224
+
225
+
226
+	/**
227
+	 * Whether the field has an explicit resolver set.
228
+	 *
229
+	 * @return boolean
230
+	 */
231
+	public function hasInternalResolver()
232
+	{
233
+		return is_callable($this->resolver);
234
+	}
235
+
236
+
237
+	/**
238
+	 * Whether the field has an explicit resolver set.
239
+	 *
240
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
241
+	 * @param array       $args    The inputArgs on the field
242
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
243
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
244
+	 * @return mixed
245
+	 * @throws LogicException
246
+	 */
247
+	public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
248
+	{
249
+		if (! $this->hasInternalResolver()) {
250
+			throw new LogicException('GraphQLField has no internal resolver.');
251
+		}
252
+		// dynamic methods using $this don't play nice
253
+		// so capture resolver to a single var first
254
+		$resolver = $this->resolver;
255
+		return $resolver($source, $args, $context, $info);
256
+	}
257
+
258
+
259
+	/**
260
+	 * Checks if the format callback is set.
261
+	 * If yes, then uses it to format the value.
262
+	 *
263
+	 * @param mixed         $value
264
+	 * @param EE_Base_Class $source
265
+	 * @return mixed The formatted value.
266
+	 * @throws InvalidDataTypeException
267
+	 * @throws InvalidInterfaceException
268
+	 * @throws InvalidArgumentException
269
+	 * @throws ReflectionException
270
+	 */
271
+	public function mayBeFormatValue($value, EE_Base_Class $source)
272
+	{
273
+		if (is_callable($this->formatter)) {
274
+			// dynamic methods using $this don't play nice
275
+			// so capture formatter to a single var first
276
+			$formatter = $this->formatter;
277
+			return $formatter($value, $source);
278
+		}
279
+		return $value;
280
+	}
281 281
 }
Please login to merge, or discard this patch.
core/services/admin/AdminPageHeaderDecoratorInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
 interface AdminPageHeaderDecoratorInterface
14 14
 {
15 15
 
16
-    /**
17
-     * @param string $text
18
-     * @return string
19
-     * @since 4.10.2.p
20
-     */
21
-    public function getHeaderText($text = '');
16
+	/**
17
+	 * @param string $text
18
+	 * @return string
19
+	 * @since 4.10.2.p
20
+	 */
21
+	public function getHeaderText($text = '');
22 22
 }
Please login to merge, or discard this patch.
core/domain/services/converters/RestApiSpoofer.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -49,137 +49,137 @@
 block discarded – undo
49 49
 class RestApiSpoofer
50 50
 {
51 51
 
52
-    /**
53
-     * @var WP_REST_Server $wp_rest_server
54
-     */
55
-    protected $wp_rest_server;
52
+	/**
53
+	 * @var WP_REST_Server $wp_rest_server
54
+	 */
55
+	protected $wp_rest_server;
56 56
 
57
-    /**
58
-     * @var Read
59
-     */
60
-    protected $rest_controller;
57
+	/**
58
+	 * @var Read
59
+	 */
60
+	protected $rest_controller;
61 61
 
62
-    /**
63
-     * @var EED_Core_Rest_Api $rest_module
64
-     */
65
-    protected $rest_module;
62
+	/**
63
+	 * @var EED_Core_Rest_Api $rest_module
64
+	 */
65
+	protected $rest_module;
66 66
 
67 67
 
68
-    /**
69
-     * RestApiSpoofer constructor.
70
-     *
71
-     * @param WP_REST_Server        $wp_rest_server
72
-     * @param EED_Core_Rest_Api $rest_module
73
-     * @param Read                  $rest_api
74
-     * @param string                $api_version
75
-     */
76
-    public function __construct(
77
-        WP_REST_Server $wp_rest_server,
78
-        EED_Core_Rest_Api $rest_module,
79
-        Read $rest_api,
80
-        $api_version = '4.8.36'
81
-    ) {
82
-        $this->wp_rest_server = $wp_rest_server;
83
-        $this->rest_module = $rest_module;
84
-        $this->rest_controller = $rest_api;
85
-        $this->rest_controller->setRequestedVersion($api_version);
86
-        $this->setUpRestServer();
87
-    }
68
+	/**
69
+	 * RestApiSpoofer constructor.
70
+	 *
71
+	 * @param WP_REST_Server        $wp_rest_server
72
+	 * @param EED_Core_Rest_Api $rest_module
73
+	 * @param Read                  $rest_api
74
+	 * @param string                $api_version
75
+	 */
76
+	public function __construct(
77
+		WP_REST_Server $wp_rest_server,
78
+		EED_Core_Rest_Api $rest_module,
79
+		Read $rest_api,
80
+		$api_version = '4.8.36'
81
+	) {
82
+		$this->wp_rest_server = $wp_rest_server;
83
+		$this->rest_module = $rest_module;
84
+		$this->rest_controller = $rest_api;
85
+		$this->rest_controller->setRequestedVersion($api_version);
86
+		$this->setUpRestServer();
87
+	}
88 88
 
89 89
 
90
-    private function setUpRestServer()
91
-    {
92
-        /* @var WP_REST_Server $wp_rest_server */
93
-        global $wp_rest_server;
94
-        $wp_rest_server = $this->wp_rest_server;
95
-        EED_Core_Rest_Api::set_hooks_both();
96
-        do_action('rest_api_init', $this->wp_rest_server);
97
-    }
90
+	private function setUpRestServer()
91
+	{
92
+		/* @var WP_REST_Server $wp_rest_server */
93
+		global $wp_rest_server;
94
+		$wp_rest_server = $this->wp_rest_server;
95
+		EED_Core_Rest_Api::set_hooks_both();
96
+		do_action('rest_api_init', $this->wp_rest_server);
97
+	}
98 98
 
99
-    /**
100
-     * @param EEM_Base $model
101
-     * @param array    $query_params
102
-     * @param string   $include
103
-     * @return array
104
-     * @throws EE_Error
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     * @throws ModelConfigurationException
109
-     * @throws ReflectionException
110
-     * @throws RestException
111
-     * @throws RestPasswordIncorrectException
112
-     * @throws RestPasswordRequiredException
113
-     * @throws UnexpectedEntityException
114
-     * @throws DomainException
115
-     * @since $VID:$
116
-     */
117
-    public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118
-    {
119
-        if (! array_key_exists('limit', $query_params)) {
120
-            $query_params['limit'] = 1;
121
-        }
122
-        $result = $this->getApiResults($model, $query_params, $include);
123
-        return is_array($result) && isset($result[0]) ? $result[0] : [];
124
-    }
99
+	/**
100
+	 * @param EEM_Base $model
101
+	 * @param array    $query_params
102
+	 * @param string   $include
103
+	 * @return array
104
+	 * @throws EE_Error
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 * @throws ModelConfigurationException
109
+	 * @throws ReflectionException
110
+	 * @throws RestException
111
+	 * @throws RestPasswordIncorrectException
112
+	 * @throws RestPasswordRequiredException
113
+	 * @throws UnexpectedEntityException
114
+	 * @throws DomainException
115
+	 * @since $VID:$
116
+	 */
117
+	public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118
+	{
119
+		if (! array_key_exists('limit', $query_params)) {
120
+			$query_params['limit'] = 1;
121
+		}
122
+		$result = $this->getApiResults($model, $query_params, $include);
123
+		return is_array($result) && isset($result[0]) ? $result[0] : [];
124
+	}
125 125
 
126
-    /**
127
-     * @param EEM_Base $model
128
-     * @param array    $query_params
129
-     * @param string   $include
130
-     * @return array
131
-     * @throws EE_Error
132
-     * @throws InvalidArgumentException
133
-     * @throws InvalidDataTypeException
134
-     * @throws InvalidInterfaceException
135
-     * @throws ModelConfigurationException
136
-     * @throws ReflectionException
137
-     * @throws RestException
138
-     * @throws RestPasswordIncorrectException
139
-     * @throws RestPasswordRequiredException
140
-     * @throws UnexpectedEntityException
141
-     * @throws DomainException
142
-     * @since $VID:$
143
-     */
144
-    public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145
-    {
146
-        if (! array_key_exists('caps', $query_params)) {
147
-            $query_params['caps'] = EEM_Base::caps_read_admin;
148
-        }
149
-        if (! array_key_exists('default_where_conditions', $query_params)) {
150
-            $query_params['default_where_conditions'] = 'none';
151
-        }
152
-        /** @type array $results */
153
-        $results = $model->get_all_wpdb_results($query_params);
154
-        $rest_request = new WP_REST_Request();
155
-        $rest_request->set_param('include', $include);
156
-        $rest_request->set_param('caps', 'edit');
157
-        $nice_results = array();
158
-        foreach ($results as $result) {
159
-            $nice_results[] = $this->rest_controller->createEntityFromWpdbResult(
160
-                $model,
161
-                $result,
162
-                $rest_request
163
-            );
164
-        }
165
-        return $nice_results;
166
-    }
126
+	/**
127
+	 * @param EEM_Base $model
128
+	 * @param array    $query_params
129
+	 * @param string   $include
130
+	 * @return array
131
+	 * @throws EE_Error
132
+	 * @throws InvalidArgumentException
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws InvalidInterfaceException
135
+	 * @throws ModelConfigurationException
136
+	 * @throws ReflectionException
137
+	 * @throws RestException
138
+	 * @throws RestPasswordIncorrectException
139
+	 * @throws RestPasswordRequiredException
140
+	 * @throws UnexpectedEntityException
141
+	 * @throws DomainException
142
+	 * @since $VID:$
143
+	 */
144
+	public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145
+	{
146
+		if (! array_key_exists('caps', $query_params)) {
147
+			$query_params['caps'] = EEM_Base::caps_read_admin;
148
+		}
149
+		if (! array_key_exists('default_where_conditions', $query_params)) {
150
+			$query_params['default_where_conditions'] = 'none';
151
+		}
152
+		/** @type array $results */
153
+		$results = $model->get_all_wpdb_results($query_params);
154
+		$rest_request = new WP_REST_Request();
155
+		$rest_request->set_param('include', $include);
156
+		$rest_request->set_param('caps', 'edit');
157
+		$nice_results = array();
158
+		foreach ($results as $result) {
159
+			$nice_results[] = $this->rest_controller->createEntityFromWpdbResult(
160
+				$model,
161
+				$result,
162
+				$rest_request
163
+			);
164
+		}
165
+		return $nice_results;
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * @param string $endpoint
171
-     * @return array
172
-     * @throws EE_Error
173
-     * @since $VID:$
174
-     */
175
-    public function getModelSchema($endpoint)
176
-    {
177
-        $response = $this->wp_rest_server->dispatch(
178
-            new WP_REST_Request(
179
-                'OPTIONS',
180
-                "/ee/v4.8.36/{$endpoint}"
181
-            )
182
-        );
183
-        return $response->get_data();
184
-    }
169
+	/**
170
+	 * @param string $endpoint
171
+	 * @return array
172
+	 * @throws EE_Error
173
+	 * @since $VID:$
174
+	 */
175
+	public function getModelSchema($endpoint)
176
+	{
177
+		$response = $this->wp_rest_server->dispatch(
178
+			new WP_REST_Request(
179
+				'OPTIONS',
180
+				"/ee/v4.8.36/{$endpoint}"
181
+			)
182
+		);
183
+		return $response->get_data();
184
+	}
185 185
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118 118
     {
119
-        if (! array_key_exists('limit', $query_params)) {
119
+        if ( ! array_key_exists('limit', $query_params)) {
120 120
             $query_params['limit'] = 1;
121 121
         }
122 122
         $result = $this->getApiResults($model, $query_params, $include);
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145 145
     {
146
-        if (! array_key_exists('caps', $query_params)) {
146
+        if ( ! array_key_exists('caps', $query_params)) {
147 147
             $query_params['caps'] = EEM_Base::caps_read_admin;
148 148
         }
149
-        if (! array_key_exists('default_where_conditions', $query_params)) {
149
+        if ( ! array_key_exists('default_where_conditions', $query_params)) {
150 150
             $query_params['default_where_conditions'] = 'none';
151 151
         }
152 152
         /** @type array $results */
Please login to merge, or discard this patch.