Completed
Branch master (d65695)
by
unknown
04:25
created
core/libraries/shortcodes/EE_Ticket_List_Shortcodes.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     private function _get_tickets_from_event(EE_Event $event)
203 203
     {
204 204
         return isset($this->_extra_data['data']->events)
205
-            ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs']
205
+            ? $this->_extra_data['data']->events[$event->ID()]['tkt_objs']
206 206
             : [];
207 207
     }
208 208
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     private function _get_ticket_list_from_registration(EE_Registration $registration)
217 217
     {
218 218
         return isset($this->_extra_data['data']->registrations)
219
-            ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']]
219
+            ? [$this->_extra_data['data']->registrations[$registration->ID()]['tkt_obj']]
220 220
             : [];
221 221
     }
222 222
 }
Please login to merge, or discard this patch.
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -18,204 +18,204 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Ticket_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    protected function _init_props()
22
-    {
23
-        $this->label       = esc_html__('Ticket List Shortcodes', 'event_espresso');
24
-        $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso');
25
-        $this->_shortcodes = [
26
-            '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'),
27
-        ];
28
-    }
29
-
30
-
31
-    /**
32
-     * @param string $shortcode
33
-     * @return string
34
-     * @throws EE_Error
35
-     * @throws ReflectionException
36
-     */
37
-    protected function _parser($shortcode)
38
-    {
39
-        switch ($shortcode) {
40
-            case '[TICKET_LIST]':
41
-                return $this->_get_ticket_list();
42
-        }
43
-        return '';
44
-    }
45
-
46
-
47
-    /**
48
-     * figure out what the incoming data is and then return the appropriate parsed value.
49
-     *
50
-     * @return string
51
-     * @throws EE_Error
52
-     * @throws ReflectionException
53
-     */
54
-    private function _get_ticket_list()
55
-    {
56
-        $this->_validate_list_requirements();
57
-
58
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
59
-            return $this->_get_ticket_list_for_main();
60
-        }
61
-        if ($this->_data['data'] instanceof EE_Registration) {
62
-            return $this->_get_ticket_list_for_attendee();
63
-        }
64
-        if ($this->_data['data'] instanceof EE_Event) {
65
-            return $this->_get_ticket_list_for_event();
66
-        }
67
-        // prevent recursive loop
68
-        return '';
69
-    }
70
-
71
-
72
-    /**
73
-     * This returns the parsed ticket list for main template;
74
-     */
75
-    private function _get_ticket_list_for_main()
76
-    {
77
-        $valid_shortcodes = [
78
-            'ticket',
79
-            'event_list',
80
-            'attendee_list',
81
-            'datetime_list',
82
-            'attendee',
83
-            'line_item_list',
84
-            'primary_registration_details',
85
-            'recipient_details',
86
-        ];
87
-        $template         = $this->_data['template'];
88
-        $data             = $this->_data['data'];
89
-        $ticket_list      = '';
90
-
91
-
92
-        // now we need to loop through the ticket list and send data to the EE_Parser helper.
93
-        foreach ($data->tickets as $ticket) {
94
-            $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template(
95
-                $template,
96
-                $ticket['ticket'],
97
-                $valid_shortcodes,
98
-                $this->_extra_data
99
-            );
100
-        }
101
-
102
-        return $ticket_list;
103
-    }
104
-
105
-
106
-    /**
107
-     * return parsed list of tickets for an event
108
-     *
109
-     * @return string
110
-     * @throws EE_Error
111
-     * @throws ReflectionException
112
-     */
113
-    private function _get_ticket_list_for_event()
114
-    {
115
-        $valid_shortcodes = [
116
-            'ticket',
117
-            'attendee_list',
118
-            'datetime_list',
119
-            'attendee',
120
-            'venue',
121
-            'line_item_list',
122
-            'primary_registration_details',
123
-            'recipient_details',
124
-        ];
125
-        $template         = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
126
-            ? $this->_data['template']['ticket_list']
127
-            : $this->_extra_data['template']['ticket_list'];
128
-        $event            = $this->_data['data'];
129
-
130
-        // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion.
131
-        $template = str_replace('[EVENT_LIST]', '', $template);
132
-
133
-        // here we're setting up the tickets for the ticket list template for THIS event.
134
-        $tkt_parsed = '';
135
-        $tickets    = $this->_get_tickets_from_event($event);
136
-
137
-        // each ticket in this case should be an ticket object.
138
-        foreach ($tickets as $ticket) {
139
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
140
-                $template,
141
-                $ticket,
142
-                $valid_shortcodes,
143
-                $this->_extra_data
144
-            );
145
-        }
146
-
147
-        return $tkt_parsed;
148
-    }
149
-
150
-
151
-    /**
152
-     * return parsed list of tickets for an attendee
153
-     *
154
-     * @return string
155
-     * @throws EE_Error
156
-     * @throws ReflectionException
157
-     */
158
-    private function _get_ticket_list_for_attendee()
159
-    {
160
-        $valid_shortcodes = [
161
-            'ticket',
162
-            'event_list',
163
-            'datetime_list',
164
-            'attendee',
165
-            'primary_registration_details',
166
-            'recipient_details',
167
-        ];
168
-
169
-        $template     = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
170
-            ? $this->_data['template']['ticket_list']
171
-            : $this->_extra_data['template']['ticket_list'];
172
-        $registration = $this->_data['data'];
173
-
174
-        // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion.
175
-        $template = str_replace('[ATTENDEE_LIST]', '', $template);
176
-
177
-        // here we're setting up the tickets for the ticket list template for THIS attendee.
178
-        $tkt_parsed = '';
179
-        $tickets    = $this->_get_ticket_list_from_registration($registration);
180
-
181
-        // each ticket in this case should be an ticket object.
182
-        foreach ($tickets as $ticket) {
183
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
184
-                $template,
185
-                $ticket,
186
-                $valid_shortcodes,
187
-                $this->_extra_data
188
-            );
189
-        }
190
-
191
-        return $tkt_parsed;
192
-    }
193
-
194
-
195
-    /**
196
-     * @param EE_Event $event
197
-     * @return array|mixed
198
-     * @throws EE_Error
199
-     * @throws ReflectionException
200
-     */
201
-    private function _get_tickets_from_event(EE_Event $event)
202
-    {
203
-        return isset($this->_extra_data['data']->events)
204
-            ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs']
205
-            : [];
206
-    }
207
-
208
-
209
-    /**
210
-     * @param EE_Registration $registration
211
-     * @return array
212
-     * @throws EE_Error
213
-     * @throws ReflectionException
214
-     */
215
-    private function _get_ticket_list_from_registration(EE_Registration $registration)
216
-    {
217
-        return isset($this->_extra_data['data']->registrations)
218
-            ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']]
219
-            : [];
220
-    }
21
+	protected function _init_props()
22
+	{
23
+		$this->label       = esc_html__('Ticket List Shortcodes', 'event_espresso');
24
+		$this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso');
25
+		$this->_shortcodes = [
26
+			'[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'),
27
+		];
28
+	}
29
+
30
+
31
+	/**
32
+	 * @param string $shortcode
33
+	 * @return string
34
+	 * @throws EE_Error
35
+	 * @throws ReflectionException
36
+	 */
37
+	protected function _parser($shortcode)
38
+	{
39
+		switch ($shortcode) {
40
+			case '[TICKET_LIST]':
41
+				return $this->_get_ticket_list();
42
+		}
43
+		return '';
44
+	}
45
+
46
+
47
+	/**
48
+	 * figure out what the incoming data is and then return the appropriate parsed value.
49
+	 *
50
+	 * @return string
51
+	 * @throws EE_Error
52
+	 * @throws ReflectionException
53
+	 */
54
+	private function _get_ticket_list()
55
+	{
56
+		$this->_validate_list_requirements();
57
+
58
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
59
+			return $this->_get_ticket_list_for_main();
60
+		}
61
+		if ($this->_data['data'] instanceof EE_Registration) {
62
+			return $this->_get_ticket_list_for_attendee();
63
+		}
64
+		if ($this->_data['data'] instanceof EE_Event) {
65
+			return $this->_get_ticket_list_for_event();
66
+		}
67
+		// prevent recursive loop
68
+		return '';
69
+	}
70
+
71
+
72
+	/**
73
+	 * This returns the parsed ticket list for main template;
74
+	 */
75
+	private function _get_ticket_list_for_main()
76
+	{
77
+		$valid_shortcodes = [
78
+			'ticket',
79
+			'event_list',
80
+			'attendee_list',
81
+			'datetime_list',
82
+			'attendee',
83
+			'line_item_list',
84
+			'primary_registration_details',
85
+			'recipient_details',
86
+		];
87
+		$template         = $this->_data['template'];
88
+		$data             = $this->_data['data'];
89
+		$ticket_list      = '';
90
+
91
+
92
+		// now we need to loop through the ticket list and send data to the EE_Parser helper.
93
+		foreach ($data->tickets as $ticket) {
94
+			$ticket_list .= $this->_shortcode_helper->parse_ticket_list_template(
95
+				$template,
96
+				$ticket['ticket'],
97
+				$valid_shortcodes,
98
+				$this->_extra_data
99
+			);
100
+		}
101
+
102
+		return $ticket_list;
103
+	}
104
+
105
+
106
+	/**
107
+	 * return parsed list of tickets for an event
108
+	 *
109
+	 * @return string
110
+	 * @throws EE_Error
111
+	 * @throws ReflectionException
112
+	 */
113
+	private function _get_ticket_list_for_event()
114
+	{
115
+		$valid_shortcodes = [
116
+			'ticket',
117
+			'attendee_list',
118
+			'datetime_list',
119
+			'attendee',
120
+			'venue',
121
+			'line_item_list',
122
+			'primary_registration_details',
123
+			'recipient_details',
124
+		];
125
+		$template         = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
126
+			? $this->_data['template']['ticket_list']
127
+			: $this->_extra_data['template']['ticket_list'];
128
+		$event            = $this->_data['data'];
129
+
130
+		// let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion.
131
+		$template = str_replace('[EVENT_LIST]', '', $template);
132
+
133
+		// here we're setting up the tickets for the ticket list template for THIS event.
134
+		$tkt_parsed = '';
135
+		$tickets    = $this->_get_tickets_from_event($event);
136
+
137
+		// each ticket in this case should be an ticket object.
138
+		foreach ($tickets as $ticket) {
139
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
140
+				$template,
141
+				$ticket,
142
+				$valid_shortcodes,
143
+				$this->_extra_data
144
+			);
145
+		}
146
+
147
+		return $tkt_parsed;
148
+	}
149
+
150
+
151
+	/**
152
+	 * return parsed list of tickets for an attendee
153
+	 *
154
+	 * @return string
155
+	 * @throws EE_Error
156
+	 * @throws ReflectionException
157
+	 */
158
+	private function _get_ticket_list_for_attendee()
159
+	{
160
+		$valid_shortcodes = [
161
+			'ticket',
162
+			'event_list',
163
+			'datetime_list',
164
+			'attendee',
165
+			'primary_registration_details',
166
+			'recipient_details',
167
+		];
168
+
169
+		$template     = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
170
+			? $this->_data['template']['ticket_list']
171
+			: $this->_extra_data['template']['ticket_list'];
172
+		$registration = $this->_data['data'];
173
+
174
+		// let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion.
175
+		$template = str_replace('[ATTENDEE_LIST]', '', $template);
176
+
177
+		// here we're setting up the tickets for the ticket list template for THIS attendee.
178
+		$tkt_parsed = '';
179
+		$tickets    = $this->_get_ticket_list_from_registration($registration);
180
+
181
+		// each ticket in this case should be an ticket object.
182
+		foreach ($tickets as $ticket) {
183
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
184
+				$template,
185
+				$ticket,
186
+				$valid_shortcodes,
187
+				$this->_extra_data
188
+			);
189
+		}
190
+
191
+		return $tkt_parsed;
192
+	}
193
+
194
+
195
+	/**
196
+	 * @param EE_Event $event
197
+	 * @return array|mixed
198
+	 * @throws EE_Error
199
+	 * @throws ReflectionException
200
+	 */
201
+	private function _get_tickets_from_event(EE_Event $event)
202
+	{
203
+		return isset($this->_extra_data['data']->events)
204
+			? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs']
205
+			: [];
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param EE_Registration $registration
211
+	 * @return array
212
+	 * @throws EE_Error
213
+	 * @throws ReflectionException
214
+	 */
215
+	private function _get_ticket_list_from_registration(EE_Registration $registration)
216
+	{
217
+		return isset($this->_extra_data['data']->registrations)
218
+			? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']]
219
+			: [];
220
+	}
221 221
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Event_List_Shortcodes.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
     private function _get_events_from_registration(EE_Registration $registration)
164 164
     {
165 165
         return isset($this->_extra_data['data']->registrations)
166
-            ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']]
166
+            ? [$this->_extra_data['data']->registrations[$registration->ID()]['evt_obj']]
167 167
             : [];
168 168
     }
169 169
 }
Please login to merge, or discard this patch.
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -18,156 +18,156 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Event_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    public function __construct()
22
-    {
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-    protected function _init_props()
28
-    {
29
-        $this->label       = esc_html__('Event List Shortcodes', 'event_espresso');
30
-        $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso');
31
-        $this->_shortcodes = [
32
-            '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'),
33
-        ];
34
-    }
35
-
36
-
37
-    /**
38
-     * @param string $shortcode
39
-     * @return string
40
-     * @throws EE_Error
41
-     * @throws ReflectionException
42
-     */
43
-    protected function _parser($shortcode)
44
-    {
45
-        switch ($shortcode) {
46
-            case '[EVENT_LIST]':
47
-                return $this->_get_event_list();
48
-        }
49
-        return '';
50
-    }
51
-
52
-
53
-    /**
54
-     * figure out what the incoming data is and then return the appropriate parsed value.
55
-     *
56
-     * @return string
57
-     * @throws EE_Error
58
-     * @throws ReflectionException
59
-     */
60
-    private function _get_event_list()
61
-    {
62
-        $this->_validate_list_requirements();
63
-
64
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
65
-            return $this->_get_event_list_for_main();
66
-        }
67
-        if ($this->_data['data'] instanceof EE_Registration) {
68
-            return $this->_get_event_list_for_registration();
69
-        }
70
-        // prevent recursive loop
71
-        return '';
72
-    }
73
-
74
-
75
-    /**
76
-     * This returns the parsed event list for main template
77
-     *
78
-     * @return string
79
-     */
80
-    private function _get_event_list_for_main()
81
-    {
82
-
83
-        $valid_shortcodes = [
84
-            'event',
85
-            'attendee_list',
86
-            'ticket_list',
87
-            'datetime_list',
88
-            'venue',
89
-            'attendee',
90
-            'recipient_list',
91
-            'recipient_details',
92
-            'primary_registration_list',
93
-            'primary_registration_details',
94
-            'event_author',
95
-            'organization',
96
-        ];
97
-        $template         = $this->_data['template'];
98
-        $data             = $this->_data['data'];
99
-        $events           = '';
100
-
101
-        // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper.
102
-        foreach ($data->events as $event) {
103
-            $events .= $this->_shortcode_helper->parse_event_list_template(
104
-                $template,
105
-                $event['event'],
106
-                $valid_shortcodes,
107
-                $this->_extra_data
108
-            );
109
-        }
110
-        return $events;
111
-    }
112
-
113
-
114
-    /**
115
-     * This returns the parsed event list for an attendee
116
-     *
117
-     * @return string
118
-     * @throws EE_Error
119
-     * @throws ReflectionException
120
-     */
121
-    private function _get_event_list_for_registration()
122
-    {
123
-        $valid_shortcodes = [
124
-            'event',
125
-            'ticket_list',
126
-            'datetime_list',
127
-            'attendee',
128
-            'event_author',
129
-            'recipient_details',
130
-            'recipient_list',
131
-            'venue',
132
-            'organization',
133
-        ];
134
-        $template         = is_array($this->_data['template']) && isset($this->_data['template']['event_list'])
135
-            ? $this->_data['template']['event_list']
136
-            : $this->_extra_data['template']['event_list'];
137
-        $registration     = $this->_data['data'];
138
-
139
-        // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion.
140
-        $template = str_replace('[ATTENDEE_LIST]', '', $template);
141
-
142
-        // here we're setting up the events for the event_list template for THIS registration.
143
-        $all_events = $this->_get_events_from_registration($registration);
144
-
145
-        // we're NOT going to prepare a list of attendees this time around
146
-        $events = '';
147
-
148
-        foreach ($all_events as $event) {
149
-            $events .= $this->_shortcode_helper->parse_event_list_template(
150
-                $template,
151
-                $event,
152
-                $valid_shortcodes,
153
-                $this->_extra_data
154
-            );
155
-        }
156
-
157
-        return $events;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param EE_Registration $registration
163
-     * @return array
164
-     * @throws EE_Error
165
-     * @throws ReflectionException
166
-     */
167
-    private function _get_events_from_registration(EE_Registration $registration)
168
-    {
169
-        return isset($this->_extra_data['data']->registrations)
170
-            ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']]
171
-            : [];
172
-    }
21
+	public function __construct()
22
+	{
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+	protected function _init_props()
28
+	{
29
+		$this->label       = esc_html__('Event List Shortcodes', 'event_espresso');
30
+		$this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso');
31
+		$this->_shortcodes = [
32
+			'[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'),
33
+		];
34
+	}
35
+
36
+
37
+	/**
38
+	 * @param string $shortcode
39
+	 * @return string
40
+	 * @throws EE_Error
41
+	 * @throws ReflectionException
42
+	 */
43
+	protected function _parser($shortcode)
44
+	{
45
+		switch ($shortcode) {
46
+			case '[EVENT_LIST]':
47
+				return $this->_get_event_list();
48
+		}
49
+		return '';
50
+	}
51
+
52
+
53
+	/**
54
+	 * figure out what the incoming data is and then return the appropriate parsed value.
55
+	 *
56
+	 * @return string
57
+	 * @throws EE_Error
58
+	 * @throws ReflectionException
59
+	 */
60
+	private function _get_event_list()
61
+	{
62
+		$this->_validate_list_requirements();
63
+
64
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
65
+			return $this->_get_event_list_for_main();
66
+		}
67
+		if ($this->_data['data'] instanceof EE_Registration) {
68
+			return $this->_get_event_list_for_registration();
69
+		}
70
+		// prevent recursive loop
71
+		return '';
72
+	}
73
+
74
+
75
+	/**
76
+	 * This returns the parsed event list for main template
77
+	 *
78
+	 * @return string
79
+	 */
80
+	private function _get_event_list_for_main()
81
+	{
82
+
83
+		$valid_shortcodes = [
84
+			'event',
85
+			'attendee_list',
86
+			'ticket_list',
87
+			'datetime_list',
88
+			'venue',
89
+			'attendee',
90
+			'recipient_list',
91
+			'recipient_details',
92
+			'primary_registration_list',
93
+			'primary_registration_details',
94
+			'event_author',
95
+			'organization',
96
+		];
97
+		$template         = $this->_data['template'];
98
+		$data             = $this->_data['data'];
99
+		$events           = '';
100
+
101
+		// now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper.
102
+		foreach ($data->events as $event) {
103
+			$events .= $this->_shortcode_helper->parse_event_list_template(
104
+				$template,
105
+				$event['event'],
106
+				$valid_shortcodes,
107
+				$this->_extra_data
108
+			);
109
+		}
110
+		return $events;
111
+	}
112
+
113
+
114
+	/**
115
+	 * This returns the parsed event list for an attendee
116
+	 *
117
+	 * @return string
118
+	 * @throws EE_Error
119
+	 * @throws ReflectionException
120
+	 */
121
+	private function _get_event_list_for_registration()
122
+	{
123
+		$valid_shortcodes = [
124
+			'event',
125
+			'ticket_list',
126
+			'datetime_list',
127
+			'attendee',
128
+			'event_author',
129
+			'recipient_details',
130
+			'recipient_list',
131
+			'venue',
132
+			'organization',
133
+		];
134
+		$template         = is_array($this->_data['template']) && isset($this->_data['template']['event_list'])
135
+			? $this->_data['template']['event_list']
136
+			: $this->_extra_data['template']['event_list'];
137
+		$registration     = $this->_data['data'];
138
+
139
+		// let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion.
140
+		$template = str_replace('[ATTENDEE_LIST]', '', $template);
141
+
142
+		// here we're setting up the events for the event_list template for THIS registration.
143
+		$all_events = $this->_get_events_from_registration($registration);
144
+
145
+		// we're NOT going to prepare a list of attendees this time around
146
+		$events = '';
147
+
148
+		foreach ($all_events as $event) {
149
+			$events .= $this->_shortcode_helper->parse_event_list_template(
150
+				$template,
151
+				$event,
152
+				$valid_shortcodes,
153
+				$this->_extra_data
154
+			);
155
+		}
156
+
157
+		return $events;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param EE_Registration $registration
163
+	 * @return array
164
+	 * @throws EE_Error
165
+	 * @throws ReflectionException
166
+	 */
167
+	private function _get_events_from_registration(EE_Registration $registration)
168
+	{
169
+		return isset($this->_extra_data['data']->registrations)
170
+			? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']]
171
+			: [];
172
+	}
173 173
 }
Please login to merge, or discard this patch.
templates/admin_general_metabox_contents_espresso_sponsors.template.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <div class="padding">
2 2
     <p>
3 3
         <?php
4
-        printf(
5
-            esc_html__(
6
-                'Upgrade to an %1$sEvent Espresso 4 support license%2$s to get access to dedicated support staff and premium features, such as a calendar, printable tickets and check-in capabilities, MailChimp integration, and more!',
7
-                'event_espresso'
8
-            ),
9
-            '<a
4
+		printf(
5
+			esc_html__(
6
+				'Upgrade to an %1$sEvent Espresso 4 support license%2$s to get access to dedicated support staff and premium features, such as a calendar, printable tickets and check-in capabilities, MailChimp integration, and more!',
7
+				'event_espresso'
8
+			),
9
+			'<a
10 10
             href="https://eventespresso.com/pricing/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=link"
11 11
             target="_blank">',
12
-            '</a>'
13
-        );
14
-        ?>
12
+			'</a>'
13
+		);
14
+		?>
15 15
     </p>
16 16
     <p>
17 17
         <a href='https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner'
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
     </p>
24 24
     <p>
25 25
         <?php
26
-        printf(
27
-            esc_html__(
28
-                'Visit %1$sEvent Espresso%2$s for more details.',
29
-                'event_espresso'
30
-            ),
31
-            '<a
26
+		printf(
27
+			esc_html__(
28
+				'Visit %1$sEvent Espresso%2$s for more details.',
29
+				'event_espresso'
30
+			),
31
+			'<a
32 32
             href="https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=link"
33 33
             target="_blank">',
34
-            '</a>'
35
-        );
36
-        ?>
34
+			'</a>'
35
+		);
36
+		?>
37 37
         </p>
38 38
 </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         <a href='https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner'
18 18
            target='_blank'>
19 19
             <img alt="<?php esc_html_e('manage events faster', 'event_espresso'); ?>"
20
-                 src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/manage-events-faster-240x240.jpg'); ?>"
20
+                 src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/manage-events-faster-240x240.jpg'); ?>"
21 21
             />
22 22
         </a>
23 23
     </p>
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/model/Meta.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
                     'table_alias'         => $field_obj->get_table_alias(),
84 84
                     'table_column'        => $field_obj->get_table_column(),
85 85
                 );
86
-                $fields_json[ $field_json['name'] ] = $field_json;
86
+                $fields_json[$field_json['name']] = $field_json;
87 87
             }
88 88
             $fields_json = array_merge(
89 89
                 $fields_json,
90 90
                 $this->getModelVersionInfo()->extraResourcePropertiesForModel($model)
91 91
             );
92
-            $response[ $model_name ]['fields'] = apply_filters(
92
+            $response[$model_name]['fields'] = apply_filters(
93 93
                 'FHEE__Meta__handle_request_models_meta__fields',
94 94
                 $fields_json,
95 95
                 $model
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
                     'type'   => str_replace('EE_', '', get_class($relation_obj)),
102 102
                     'single' => $relation_obj instanceof EE_Belongs_To_Relation,
103 103
                 );
104
-                $relations_json[ $relation_name ] = $relation_json;
104
+                $relations_json[$relation_name] = $relation_json;
105 105
             }
106
-            $response[ $model_name ]['relations'] = apply_filters(
106
+            $response[$model_name]['relations'] = apply_filters(
107 107
                 'FHEE__Meta__handle_request_models_meta__relations',
108 108
                 $relations_json,
109 109
                 $model
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                 'name'    => $addon->name(),
129 129
                 'version' => $addon->version(),
130 130
             );
131
-            $addons[ $addon_json['name'] ] = $addon_json;
131
+            $addons[$addon_json['name']] = $addon_json;
132 132
         }
133 133
         $response_data['ee'] = array(
134 134
             'version'              => EEM_System_Status::instance()->get_ee_version(),
Please login to merge, or discard this patch.
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -24,122 +24,122 @@
 block discarded – undo
24 24
  */
25 25
 class Meta extends Base
26 26
 {
27
-    /**
28
-     * @param WP_REST_Request $request
29
-     * @param string           $version
30
-     * @return array|WP_REST_Response
31
-     */
32
-    public static function handleRequestModelsMeta(WP_REST_Request $request, $version)
33
-    {
34
-        $controller = new Meta();
35
-        try {
36
-            $controller->setRequestedVersion($version);
37
-            return $controller->sendResponse($controller->getModelsMetadataEntity());
38
-        } catch (Exception $e) {
39
-            return $controller->sendResponse($e);
40
-        }
41
-    }
27
+	/**
28
+	 * @param WP_REST_Request $request
29
+	 * @param string           $version
30
+	 * @return array|WP_REST_Response
31
+	 */
32
+	public static function handleRequestModelsMeta(WP_REST_Request $request, $version)
33
+	{
34
+		$controller = new Meta();
35
+		try {
36
+			$controller->setRequestedVersion($version);
37
+			return $controller->sendResponse($controller->getModelsMetadataEntity());
38
+		} catch (Exception $e) {
39
+			return $controller->sendResponse($e);
40
+		}
41
+	}
42 42
 
43 43
 
44
-    /*
44
+	/*
45 45
      * Gets the model metadata resource entity
46 46
      * @return array for JSON response, describing all the models available in teh requested version
47 47
      */
48
-    protected function getModelsMetadataEntity()
49
-    {
50
-        $response = array();
51
-        foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) {
52
-            $model = $this->getModelVersionInfo()->loadModel($model_name);
53
-            $fields_json = array();
54
-            foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) {
55
-                if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) {
56
-                    continue;
57
-                }
58
-                if ($field_obj instanceof EE_Boolean_Field) {
59
-                    $datatype = 'Boolean';
60
-                } elseif ($field_obj->get_wpdb_data_type() == '%d') {
61
-                    $datatype = 'Number';
62
-                } elseif ($field_name instanceof EE_Serialized_Text_Field) {
63
-                    $datatype = 'Object';
64
-                } else {
65
-                    $datatype = 'String';
66
-                }
67
-                $default_value = ModelDataTranslator::prepareFieldValueForJson(
68
-                    $field_obj,
69
-                    $field_obj->get_default_value(),
70
-                    $this->getModelVersionInfo()->requestedVersion()
71
-                );
72
-                $field_json = array(
73
-                    'name'                => $field_name,
74
-                    'nicename'            => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES),
75
-                    'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj),
76
-                    'has_pretty_format'   => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj),
77
-                    'type'                => str_replace('EE_', '', get_class($field_obj)),
78
-                    'datatype'            => $datatype,
79
-                    'nullable'            => $field_obj->is_nullable(),
80
-                    'default'             => $default_value,
81
-                    'table_alias'         => $field_obj->get_table_alias(),
82
-                    'table_column'        => $field_obj->get_table_column(),
83
-                );
84
-                $fields_json[ $field_json['name'] ] = $field_json;
85
-            }
86
-            $fields_json = array_merge(
87
-                $fields_json,
88
-                $this->getModelVersionInfo()->extraResourcePropertiesForModel($model)
89
-            );
90
-            $response[ $model_name ]['fields'] = apply_filters(
91
-                'FHEE__Meta__handle_request_models_meta__fields',
92
-                $fields_json,
93
-                $model
94
-            );
95
-            $relations_json = array();
96
-            foreach ($model->relation_settings() as $relation_name => $relation_obj) {
97
-                $relation_json = array(
98
-                    'name'   => $relation_name,
99
-                    'type'   => str_replace('EE_', '', get_class($relation_obj)),
100
-                    'single' => $relation_obj instanceof EE_Belongs_To_Relation,
101
-                );
102
-                $relations_json[ $relation_name ] = $relation_json;
103
-            }
104
-            $response[ $model_name ]['relations'] = apply_filters(
105
-                'FHEE__Meta__handle_request_models_meta__relations',
106
-                $relations_json,
107
-                $model
108
-            );
109
-        }
110
-        return $response;
111
-    }
48
+	protected function getModelsMetadataEntity()
49
+	{
50
+		$response = array();
51
+		foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) {
52
+			$model = $this->getModelVersionInfo()->loadModel($model_name);
53
+			$fields_json = array();
54
+			foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) {
55
+				if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) {
56
+					continue;
57
+				}
58
+				if ($field_obj instanceof EE_Boolean_Field) {
59
+					$datatype = 'Boolean';
60
+				} elseif ($field_obj->get_wpdb_data_type() == '%d') {
61
+					$datatype = 'Number';
62
+				} elseif ($field_name instanceof EE_Serialized_Text_Field) {
63
+					$datatype = 'Object';
64
+				} else {
65
+					$datatype = 'String';
66
+				}
67
+				$default_value = ModelDataTranslator::prepareFieldValueForJson(
68
+					$field_obj,
69
+					$field_obj->get_default_value(),
70
+					$this->getModelVersionInfo()->requestedVersion()
71
+				);
72
+				$field_json = array(
73
+					'name'                => $field_name,
74
+					'nicename'            => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES),
75
+					'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj),
76
+					'has_pretty_format'   => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj),
77
+					'type'                => str_replace('EE_', '', get_class($field_obj)),
78
+					'datatype'            => $datatype,
79
+					'nullable'            => $field_obj->is_nullable(),
80
+					'default'             => $default_value,
81
+					'table_alias'         => $field_obj->get_table_alias(),
82
+					'table_column'        => $field_obj->get_table_column(),
83
+				);
84
+				$fields_json[ $field_json['name'] ] = $field_json;
85
+			}
86
+			$fields_json = array_merge(
87
+				$fields_json,
88
+				$this->getModelVersionInfo()->extraResourcePropertiesForModel($model)
89
+			);
90
+			$response[ $model_name ]['fields'] = apply_filters(
91
+				'FHEE__Meta__handle_request_models_meta__fields',
92
+				$fields_json,
93
+				$model
94
+			);
95
+			$relations_json = array();
96
+			foreach ($model->relation_settings() as $relation_name => $relation_obj) {
97
+				$relation_json = array(
98
+					'name'   => $relation_name,
99
+					'type'   => str_replace('EE_', '', get_class($relation_obj)),
100
+					'single' => $relation_obj instanceof EE_Belongs_To_Relation,
101
+				);
102
+				$relations_json[ $relation_name ] = $relation_json;
103
+			}
104
+			$response[ $model_name ]['relations'] = apply_filters(
105
+				'FHEE__Meta__handle_request_models_meta__relations',
106
+				$relations_json,
107
+				$model
108
+			);
109
+		}
110
+		return $response;
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     * Adds EE metadata to the index
116
-     *
117
-     * @param WP_REST_Response $rest_response_obj
118
-     * @return WP_REST_Response
119
-     */
120
-    public static function filterEeMetadataIntoIndex(WP_REST_Response $rest_response_obj)
121
-    {
122
-        $response_data = $rest_response_obj->get_data();
123
-        $addons = array();
124
-        foreach (EE_Registry::instance()->addons as $addon) {
125
-            $addon_json = array(
126
-                'name'    => $addon->name(),
127
-                'version' => $addon->version(),
128
-            );
129
-            $addons[ $addon_json['name'] ] = $addon_json;
130
-        }
131
-        $response_data['ee'] = array(
132
-            'version'              => EEM_System_Status::instance()->get_ee_version(),
133
-            // @codingStandardsIgnoreStart
134
-            'documentation_url'    => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API',
135
-            // @codingStandardsIgnoreEnd
136
-            'addons'               => $addons,
137
-            'maintenance_mode'     => EE_Maintenance_Mode::instance()->real_level(),
138
-            'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()),
139
-        );
140
-        $rest_response_obj->set_data($response_data);
141
-        return $rest_response_obj;
142
-    }
114
+	/**
115
+	 * Adds EE metadata to the index
116
+	 *
117
+	 * @param WP_REST_Response $rest_response_obj
118
+	 * @return WP_REST_Response
119
+	 */
120
+	public static function filterEeMetadataIntoIndex(WP_REST_Response $rest_response_obj)
121
+	{
122
+		$response_data = $rest_response_obj->get_data();
123
+		$addons = array();
124
+		foreach (EE_Registry::instance()->addons as $addon) {
125
+			$addon_json = array(
126
+				'name'    => $addon->name(),
127
+				'version' => $addon->version(),
128
+			);
129
+			$addons[ $addon_json['name'] ] = $addon_json;
130
+		}
131
+		$response_data['ee'] = array(
132
+			'version'              => EEM_System_Status::instance()->get_ee_version(),
133
+			// @codingStandardsIgnoreStart
134
+			'documentation_url'    => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API',
135
+			// @codingStandardsIgnoreEnd
136
+			'addons'               => $addons,
137
+			'maintenance_mode'     => EE_Maintenance_Mode::instance()->real_level(),
138
+			'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()),
139
+		);
140
+		$rest_response_obj->set_data($response_data);
141
+		return $rest_response_obj;
142
+	}
143 143
 }
144 144
 
145 145
 
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/PriceConnectionResolver.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -80,24 +80,24 @@  discard block
 block discarded – undo
80 80
          * Collect the input_fields and sanitize them to prepare them for sending to the Query
81 81
          */
82 82
         $input_fields = [];
83
-        if (! empty($this->args['where'])) {
83
+        if ( ! empty($this->args['where'])) {
84 84
             $input_fields = $this->sanitizeInputFields($this->args['where']);
85 85
 
86 86
             // Use the proper operator.
87
-            if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) {
87
+            if ( ! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) {
88 88
                 $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']];
89 89
             }
90
-            if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) {
90
+            if ( ! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) {
91 91
                 $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']];
92 92
             }
93
-            if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) {
93
+            if ( ! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) {
94 94
                 $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']];
95 95
             }
96
-            if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) {
96
+            if ( ! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) {
97 97
                 $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']];
98 98
             }
99 99
             // if event ID is passed but not a ticket ID
100
-            if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) {
100
+            if ( ! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) {
101 101
                 $event_id = $input_fields['Event.EVT_ID'];
102 102
                 // Ensure that this doesn't go to the query.
103 103
                 // After all there is no DB relation between event and price
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         /**
133 133
          * Merge the input_fields with the default query_args
134 134
          */
135
-        if (! empty($input_fields)) {
135
+        if ( ! empty($input_fields)) {
136 136
             $where_params = array_merge($where_params, $input_fields);
137 137
         }
138 138
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $default_prices_params = [];
142 142
 
143 143
         // If default ticket prices should be included.
144
-        if (! empty($this->args['where']['includeDefaultTicketsPrices'])) {
144
+        if ( ! empty($this->args['where']['includeDefaultTicketsPrices'])) {
145 145
             $default_ticket_ids = EEM_Ticket::instance()->get_col([
146 146
                 [
147 147
                     'TKT_is_default' => 1,
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             ]);
151 151
 
152 152
             // if we have default tickets
153
-            if (! empty($default_ticket_ids)) {
153
+            if ( ! empty($default_ticket_ids)) {
154 154
                 $default_prices_params['OR'] = [
155 155
                     'Ticket.TKT_ID' => ['IN', $default_ticket_ids],
156 156
                 ];
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
         }
159 159
 
160 160
         // If default prices should be included.
161
-        if (! empty($this->args['where']['includeDefaultPrices'])) {
161
+        if ( ! empty($this->args['where']['includeDefaultPrices'])) {
162 162
             $default_prices_params['AND'] = [
163 163
                 'PRC_deleted'    => 0,
164 164
                 'PRC_is_default' => 1,
165 165
             ];
166 166
         }
167 167
 
168
-        if (! empty($default_prices_params)) {
168
+        if ( ! empty($default_prices_params)) {
169 169
             if (empty($where_params)) {
170 170
                 $where_params['OR'] = $default_prices_params;
171 171
             } else {
Please login to merge, or discard this patch.
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -17,219 +17,219 @@
 block discarded – undo
17 17
  */
18 18
 class PriceConnectionResolver extends AbstractConnectionResolver
19 19
 {
20
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
21
-    public function get_loader_name(): string
22
-    {
23
-        return 'espresso_price';
24
-    }
25
-
26
-    /**
27
-     * @return EEM_Price
28
-     * @throws EE_Error
29
-     * @throws InvalidArgumentException
30
-     * @throws InvalidDataTypeException
31
-     * @throws InvalidInterfaceException
32
-     * @throws ReflectionException
33
-     */
34
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
-    public function get_query(): EEM_Price
36
-    {
37
-        return EEM_Price::instance();
38
-    }
39
-
40
-
41
-    /**
42
-     * Return an array of item IDs from the query
43
-     *
44
-     * @return array
45
-     */
46
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
47
-    public function get_ids(): array
48
-    {
49
-        $results = $this->query->get_col($this->query_args);
50
-
51
-        return ! empty($results) ? $results : [];
52
-    }
53
-
54
-
55
-    /**
56
-     * Here, we map the args from the input, then we make sure that we're only querying
57
-     * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
58
-     * handle batch resolution of the posts.
59
-     *
60
-     * @return array
61
-     * @throws EE_Error
62
-     * @throws InvalidArgumentException
63
-     * @throws ReflectionException
64
-     * @throws InvalidDataTypeException
65
-     * @throws InvalidInterfaceException
66
-     */
67
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
68
-    public function get_query_args(): array
69
-    {
70
-        $where_params = [];
71
-        $query_args   = [];
72
-
73
-        $query_args['limit'] = $this->getLimit();
74
-
75
-        // Avoid multiple entries by join.
76
-        $query_args['group_by'] = 'PRC_ID';
77
-
78
-        $query_args['default_where_conditions'] = 'minimum';
79
-
80
-        /**
81
-         * Collect the input_fields and sanitize them to prepare them for sending to the Query
82
-         */
83
-        $input_fields = [];
84
-        if (! empty($this->args['where'])) {
85
-            $input_fields = $this->sanitizeInputFields($this->args['where']);
86
-
87
-            // Use the proper operator.
88
-            if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) {
89
-                $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']];
90
-            }
91
-            if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) {
92
-                $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']];
93
-            }
94
-            if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) {
95
-                $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']];
96
-            }
97
-            if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) {
98
-                $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']];
99
-            }
100
-            // if event ID is passed but not a ticket ID
101
-            if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) {
102
-                $event_id = $input_fields['Event.EVT_ID'];
103
-                // Ensure that this doesn't go to the query.
104
-                // After all there is no DB relation between event and price
105
-                unset($input_fields['Event.EVT_ID']);
106
-                // get all the datetimeIds of the event
107
-                $event_datetime_ids = EEM_Datetime::instance()->get_col([
108
-                    [
109
-                        'EVT_ID'      => $event_id,
110
-                    ],
111
-                    'default_where_conditions' => 'minimum'
112
-                ]);
113
-                // get all the related ticket Ids
114
-                $ticket_ids = EEM_Ticket::instance()->get_col([
115
-                    [
116
-                        'Datetime.DTT_ID' => ['IN', $event_datetime_ids],
117
-                    ],
118
-                    'default_where_conditions' => 'minimum'
119
-                ]);
120
-
121
-                // add tickets relation to the query
122
-                $input_fields['Ticket.TKT_ID'] = ['IN', $ticket_ids];
123
-            }
124
-        }
125
-
126
-        /**
127
-         * Determine where we're at in the Graph and adjust the query context appropriately.
128
-         */
129
-        if ($this->source instanceof EE_Ticket) {
130
-            $where_params['Ticket.TKT_ID'] = $this->source->ID();
131
-        }
132
-
133
-        /**
134
-         * Merge the input_fields with the default query_args
135
-         */
136
-        if (! empty($input_fields)) {
137
-            $where_params = array_merge($where_params, $input_fields);
138
-        }
139
-
140
-        [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID');
141
-
142
-        $default_prices_params = [];
143
-
144
-        // If default ticket prices should be included.
145
-        if (! empty($this->args['where']['includeDefaultTicketsPrices'])) {
146
-            $default_ticket_ids = EEM_Ticket::instance()->get_col([
147
-                [
148
-                    'TKT_is_default' => 1,
149
-                ],
150
-                'default_where_conditions' => 'minimum'
151
-            ]);
152
-
153
-            // if we have default tickets
154
-            if (! empty($default_ticket_ids)) {
155
-                $default_prices_params['OR'] = [
156
-                    'Ticket.TKT_ID' => ['IN', $default_ticket_ids],
157
-                ];
158
-            }
159
-        }
160
-
161
-        // If default prices should be included.
162
-        if (! empty($this->args['where']['includeDefaultPrices'])) {
163
-            $default_prices_params['AND'] = [
164
-                'PRC_deleted'    => 0,
165
-                'PRC_is_default' => 1,
166
-            ];
167
-        }
168
-
169
-        if (! empty($default_prices_params)) {
170
-            if (empty($where_params)) {
171
-                $where_params['OR'] = $default_prices_params;
172
-            } else {
173
-                $where_params = [
174
-                    'OR' => [
175
-                        'OR'  => $default_prices_params,
176
-                        'AND' => $where_params,
177
-                    ],
178
-                ];
179
-            }
180
-        }
181
-
182
-        $where_params = apply_filters(
183
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_where_params',
184
-            $where_params,
185
-            $this->source,
186
-            $this->args
187
-        );
188
-
189
-        $query_args[] = $where_params;
190
-
191
-        /**
192
-         * Return the $query_args
193
-         */
194
-        return apply_filters(
195
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_query_args',
196
-            $query_args,
197
-            $this->source,
198
-            $this->args
199
-        );
200
-    }
201
-
202
-
203
-    /**
204
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
205
-     * friendly keys.
206
-     *
207
-     * @param array $where_args
208
-     * @return array
209
-     */
210
-    public function sanitizeInputFields(array $where_args): array
211
-    {
212
-        $arg_mapping = [
213
-            'in'              => 'PRC_ID',
214
-            'idIn'            => 'PRC_ID',
215
-            'isDefault'       => 'PRC_is_default',
216
-            'event'           => 'Event.EVT_ID',
217
-            'eventId'         => 'Event.EVT_ID', // priority.
218
-            'ticket'          => 'Ticket.TKT_ID',
219
-            'ticketIn'        => 'Ticket.TKT_ID',
220
-            'ticketIdIn'      => 'Ticket.TKT_ID',
221
-            'ticketId'        => 'Ticket.TKT_ID', // priority.
222
-            'priceType'       => 'Price_Type.PRT_ID',
223
-            'priceTypeIn'     => 'Price_Type.PRT_ID',
224
-            'priceTypeIdIn'   => 'Price_Type.PRT_ID',
225
-            'priceTypeId'     => 'Price_Type.PRT_ID', // priority.
226
-            'priceBaseType'   => 'Price_Type.PBT_ID',
227
-            'priceBaseTypeIn' => 'Price_Type.PBT_ID',
228
-        ];
229
-        return $this->sanitizeWhereArgsForInputFields(
230
-            $where_args,
231
-            $arg_mapping,
232
-            ['in', 'event', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn']
233
-        );
234
-    }
20
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
21
+	public function get_loader_name(): string
22
+	{
23
+		return 'espresso_price';
24
+	}
25
+
26
+	/**
27
+	 * @return EEM_Price
28
+	 * @throws EE_Error
29
+	 * @throws InvalidArgumentException
30
+	 * @throws InvalidDataTypeException
31
+	 * @throws InvalidInterfaceException
32
+	 * @throws ReflectionException
33
+	 */
34
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
+	public function get_query(): EEM_Price
36
+	{
37
+		return EEM_Price::instance();
38
+	}
39
+
40
+
41
+	/**
42
+	 * Return an array of item IDs from the query
43
+	 *
44
+	 * @return array
45
+	 */
46
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
47
+	public function get_ids(): array
48
+	{
49
+		$results = $this->query->get_col($this->query_args);
50
+
51
+		return ! empty($results) ? $results : [];
52
+	}
53
+
54
+
55
+	/**
56
+	 * Here, we map the args from the input, then we make sure that we're only querying
57
+	 * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
58
+	 * handle batch resolution of the posts.
59
+	 *
60
+	 * @return array
61
+	 * @throws EE_Error
62
+	 * @throws InvalidArgumentException
63
+	 * @throws ReflectionException
64
+	 * @throws InvalidDataTypeException
65
+	 * @throws InvalidInterfaceException
66
+	 */
67
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
68
+	public function get_query_args(): array
69
+	{
70
+		$where_params = [];
71
+		$query_args   = [];
72
+
73
+		$query_args['limit'] = $this->getLimit();
74
+
75
+		// Avoid multiple entries by join.
76
+		$query_args['group_by'] = 'PRC_ID';
77
+
78
+		$query_args['default_where_conditions'] = 'minimum';
79
+
80
+		/**
81
+		 * Collect the input_fields and sanitize them to prepare them for sending to the Query
82
+		 */
83
+		$input_fields = [];
84
+		if (! empty($this->args['where'])) {
85
+			$input_fields = $this->sanitizeInputFields($this->args['where']);
86
+
87
+			// Use the proper operator.
88
+			if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) {
89
+				$input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']];
90
+			}
91
+			if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) {
92
+				$input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']];
93
+			}
94
+			if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) {
95
+				$input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']];
96
+			}
97
+			if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) {
98
+				$input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']];
99
+			}
100
+			// if event ID is passed but not a ticket ID
101
+			if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) {
102
+				$event_id = $input_fields['Event.EVT_ID'];
103
+				// Ensure that this doesn't go to the query.
104
+				// After all there is no DB relation between event and price
105
+				unset($input_fields['Event.EVT_ID']);
106
+				// get all the datetimeIds of the event
107
+				$event_datetime_ids = EEM_Datetime::instance()->get_col([
108
+					[
109
+						'EVT_ID'      => $event_id,
110
+					],
111
+					'default_where_conditions' => 'minimum'
112
+				]);
113
+				// get all the related ticket Ids
114
+				$ticket_ids = EEM_Ticket::instance()->get_col([
115
+					[
116
+						'Datetime.DTT_ID' => ['IN', $event_datetime_ids],
117
+					],
118
+					'default_where_conditions' => 'minimum'
119
+				]);
120
+
121
+				// add tickets relation to the query
122
+				$input_fields['Ticket.TKT_ID'] = ['IN', $ticket_ids];
123
+			}
124
+		}
125
+
126
+		/**
127
+		 * Determine where we're at in the Graph and adjust the query context appropriately.
128
+		 */
129
+		if ($this->source instanceof EE_Ticket) {
130
+			$where_params['Ticket.TKT_ID'] = $this->source->ID();
131
+		}
132
+
133
+		/**
134
+		 * Merge the input_fields with the default query_args
135
+		 */
136
+		if (! empty($input_fields)) {
137
+			$where_params = array_merge($where_params, $input_fields);
138
+		}
139
+
140
+		[$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID');
141
+
142
+		$default_prices_params = [];
143
+
144
+		// If default ticket prices should be included.
145
+		if (! empty($this->args['where']['includeDefaultTicketsPrices'])) {
146
+			$default_ticket_ids = EEM_Ticket::instance()->get_col([
147
+				[
148
+					'TKT_is_default' => 1,
149
+				],
150
+				'default_where_conditions' => 'minimum'
151
+			]);
152
+
153
+			// if we have default tickets
154
+			if (! empty($default_ticket_ids)) {
155
+				$default_prices_params['OR'] = [
156
+					'Ticket.TKT_ID' => ['IN', $default_ticket_ids],
157
+				];
158
+			}
159
+		}
160
+
161
+		// If default prices should be included.
162
+		if (! empty($this->args['where']['includeDefaultPrices'])) {
163
+			$default_prices_params['AND'] = [
164
+				'PRC_deleted'    => 0,
165
+				'PRC_is_default' => 1,
166
+			];
167
+		}
168
+
169
+		if (! empty($default_prices_params)) {
170
+			if (empty($where_params)) {
171
+				$where_params['OR'] = $default_prices_params;
172
+			} else {
173
+				$where_params = [
174
+					'OR' => [
175
+						'OR'  => $default_prices_params,
176
+						'AND' => $where_params,
177
+					],
178
+				];
179
+			}
180
+		}
181
+
182
+		$where_params = apply_filters(
183
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_where_params',
184
+			$where_params,
185
+			$this->source,
186
+			$this->args
187
+		);
188
+
189
+		$query_args[] = $where_params;
190
+
191
+		/**
192
+		 * Return the $query_args
193
+		 */
194
+		return apply_filters(
195
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_query_args',
196
+			$query_args,
197
+			$this->source,
198
+			$this->args
199
+		);
200
+	}
201
+
202
+
203
+	/**
204
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
205
+	 * friendly keys.
206
+	 *
207
+	 * @param array $where_args
208
+	 * @return array
209
+	 */
210
+	public function sanitizeInputFields(array $where_args): array
211
+	{
212
+		$arg_mapping = [
213
+			'in'              => 'PRC_ID',
214
+			'idIn'            => 'PRC_ID',
215
+			'isDefault'       => 'PRC_is_default',
216
+			'event'           => 'Event.EVT_ID',
217
+			'eventId'         => 'Event.EVT_ID', // priority.
218
+			'ticket'          => 'Ticket.TKT_ID',
219
+			'ticketIn'        => 'Ticket.TKT_ID',
220
+			'ticketIdIn'      => 'Ticket.TKT_ID',
221
+			'ticketId'        => 'Ticket.TKT_ID', // priority.
222
+			'priceType'       => 'Price_Type.PRT_ID',
223
+			'priceTypeIn'     => 'Price_Type.PRT_ID',
224
+			'priceTypeIdIn'   => 'Price_Type.PRT_ID',
225
+			'priceTypeId'     => 'Price_Type.PRT_ID', // priority.
226
+			'priceBaseType'   => 'Price_Type.PBT_ID',
227
+			'priceBaseTypeIn' => 'Price_Type.PBT_ID',
228
+		];
229
+		return $this->sanitizeWhereArgsForInputFields(
230
+			$where_args,
231
+			$arg_mapping,
232
+			['in', 'event', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn']
233
+		);
234
+	}
235 235
 }
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/TicketConnectionResolver.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
          * Collect the input_fields and sanitize them to prepare them for sending to the Query
79 79
          */
80 80
         $input_fields = [];
81
-        if (! empty($this->args['where'])) {
81
+        if ( ! empty($this->args['where'])) {
82 82
             $input_fields = $this->sanitizeInputFields($this->args['where']);
83 83
 
84 84
             // Use the proper operator.
85
-            if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) {
85
+            if ( ! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) {
86 86
                 $input_fields['Datetime.DTT_ID'] = ['IN', $input_fields['Datetime.DTT_ID']];
87 87
             }
88
-            if (! empty($input_fields['Datetime.EVT_ID']) && is_array($input_fields['Datetime.EVT_ID'])) {
88
+            if ( ! empty($input_fields['Datetime.EVT_ID']) && is_array($input_fields['Datetime.EVT_ID'])) {
89 89
                 $input_fields['Datetime.EVT_ID'] = ['IN', $input_fields['Datetime.EVT_ID']];
90 90
             }
91 91
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         /**
101 101
          * Merge the input_fields with the default query_args
102 102
          */
103
-        if (! empty($input_fields)) {
103
+        if ( ! empty($input_fields)) {
104 104
             $where_params = array_merge($where_params, $input_fields);
105 105
         }
106 106
 
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
 
109 109
         $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : '';
110 110
 
111
-        if (! empty($search)) {
111
+        if ( ! empty($search)) {
112 112
             // use OR operator to search in any of the fields
113 113
             $where_params['OR'] = array(
114
-                'TKT_name'        => array('LIKE', '%' . $search . '%'),
115
-                'TKT_description' => array('LIKE', '%' . $search . '%'),
114
+                'TKT_name'        => array('LIKE', '%'.$search.'%'),
115
+                'TKT_description' => array('LIKE', '%'.$search.'%'),
116 116
             );
117 117
         }
118 118
 
119 119
         // If default tickets should be included.
120
-        if (! empty($this->args['where']['includeDefaultTickets'])) {
120
+        if ( ! empty($this->args['where']['includeDefaultTickets'])) {
121 121
             /**
122 122
              * We need to get each ticket that
123 123
              * - satisfies $where_params above
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -15,178 +15,178 @@
 block discarded – undo
15 15
  */
16 16
 class TicketConnectionResolver extends AbstractConnectionResolver
17 17
 {
18
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
19
-    public function get_loader_name(): string
20
-    {
21
-        return 'espresso_ticket';
22
-    }
23
-
24
-    /**
25
-     * @return EEM_Ticket
26
-     * @throws EE_Error
27
-     * @throws InvalidArgumentException
28
-     * @throws InvalidDataTypeException
29
-     * @throws InvalidInterfaceException
30
-     * @throws ReflectionException
31
-     */
32
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
33
-    public function get_query(): EEM_Ticket
34
-    {
35
-        return EEM_Ticket::instance();
36
-    }
37
-
38
-
39
-    /**
40
-     * Return an array of item IDs from the query
41
-     *
42
-     * @return array
43
-     */
44
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45
-    public function get_ids(): array
46
-    {
47
-        $results = $this->query->get_col($this->query_args);
48
-
49
-        return ! empty($results) ? $results : [];
50
-    }
51
-
52
-
53
-    /**
54
-     * Here, we map the args from the input, then we make sure that we're only querying
55
-     * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
56
-     * handle batch resolution of the posts.
57
-     *
58
-     * @return array
59
-     * @throws EE_Error
60
-     * @throws InvalidArgumentException
61
-     * @throws ReflectionException
62
-     * @throws InvalidDataTypeException
63
-     * @throws InvalidInterfaceException
64
-     */
65
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
66
-    public function get_query_args(): array
67
-    {
68
-        $where_params = ['TKT_deleted' => ['IN', [true, false]]];
69
-        $query_args   = [];
70
-
71
-        $query_args['limit'] = $this->getLimit();
72
-
73
-        // Avoid multiple entries by join.
74
-        $query_args['group_by'] = 'TKT_ID';
75
-
76
-        $query_args['default_where_conditions'] = 'minimum';
77
-
78
-        /**
79
-         * Collect the input_fields and sanitize them to prepare them for sending to the Query
80
-         */
81
-        $input_fields = [];
82
-        if (! empty($this->args['where'])) {
83
-            $input_fields = $this->sanitizeInputFields($this->args['where']);
84
-
85
-            // Use the proper operator.
86
-            if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) {
87
-                $input_fields['Datetime.DTT_ID'] = ['IN', $input_fields['Datetime.DTT_ID']];
88
-            }
89
-            if (! empty($input_fields['Datetime.EVT_ID']) && is_array($input_fields['Datetime.EVT_ID'])) {
90
-                $input_fields['Datetime.EVT_ID'] = ['IN', $input_fields['Datetime.EVT_ID']];
91
-            }
92
-        }
93
-
94
-        /**
95
-         * Determine where we're at in the Graph and adjust the query context appropriately.
96
-         */
97
-        if ($this->source instanceof EE_Datetime) {
98
-            $where_params['Datetime.DTT_ID'] = $this->source->ID();
99
-        }
100
-
101
-        /**
102
-         * Merge the input_fields with the default query_args
103
-         */
104
-        if (! empty($input_fields)) {
105
-            $where_params = array_merge($where_params, $input_fields);
106
-        }
107
-
108
-        [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID');
109
-
110
-        $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : '';
111
-
112
-        if (! empty($search)) {
113
-            // use OR operator to search in any of the fields
114
-            $where_params['OR'] = array(
115
-                'TKT_name'        => array('LIKE', '%' . $search . '%'),
116
-                'TKT_description' => array('LIKE', '%' . $search . '%'),
117
-            );
118
-        }
119
-
120
-        // If default tickets should be included.
121
-        if (! empty($this->args['where']['includeDefaultTickets'])) {
122
-            /**
123
-             * We need to get each ticket that
124
-             * - satisfies $where_params above
125
-             * OR
126
-             * - it's a default ticket
127
-             */
128
-            $where_params = [
129
-                'OR' => [
130
-                    // use extra OR instead of AND to avoid it getting overridden
131
-                    'OR' => [
132
-                        'AND' => [
133
-                            'TKT_deleted'    => ['IN', [true, false]],
134
-                            'TKT_is_default' => 1,
135
-                        ]
136
-                    ],
137
-                    'AND' => $where_params,
138
-                ],
139
-            ];
140
-        }
141
-
142
-        $where_params = apply_filters(
143
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_where_params',
144
-            $where_params,
145
-            $this->source,
146
-            $this->args
147
-        );
148
-
149
-        $query_args[] = $where_params;
150
-
151
-        /**
152
-         * Return the $query_args
153
-         */
154
-        return apply_filters(
155
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_query_args',
156
-            $query_args,
157
-            $this->source,
158
-            $this->args
159
-        );
160
-    }
161
-
162
-
163
-    /**
164
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
165
-     * friendly keys.
166
-     *
167
-     * @param array $where_args
168
-     * @return array
169
-     */
170
-    public function sanitizeInputFields(array $where_args): array
171
-    {
172
-        $arg_mapping = [
173
-            'event'        => 'Datetime.EVT_ID',
174
-            'eventIn'      => 'Datetime.EVT_ID',
175
-            'eventIdIn'    => 'Datetime.EVT_ID',
176
-            'eventId'      => 'Datetime.EVT_ID', // priority.
177
-            'datetime'     => 'Datetime.DTT_ID',
178
-            'datetimeIn'   => 'Datetime.DTT_ID',
179
-            'datetimeIdIn' => 'Datetime.DTT_ID',
180
-            'datetimeId'   => 'Datetime.DTT_ID', // priority.
181
-            'isDefault'    => 'TKT_is_default',
182
-            'isRequired'   => 'TKT_required',
183
-            'isTaxable'    => 'TKT_taxable',
184
-            'isTrashed'    => 'TKT_deleted',
185
-        ];
186
-        return $this->sanitizeWhereArgsForInputFields(
187
-            $where_args,
188
-            $arg_mapping,
189
-            ['datetime', 'datetimeIn', 'event', 'eventIn']
190
-        );
191
-    }
18
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
19
+	public function get_loader_name(): string
20
+	{
21
+		return 'espresso_ticket';
22
+	}
23
+
24
+	/**
25
+	 * @return EEM_Ticket
26
+	 * @throws EE_Error
27
+	 * @throws InvalidArgumentException
28
+	 * @throws InvalidDataTypeException
29
+	 * @throws InvalidInterfaceException
30
+	 * @throws ReflectionException
31
+	 */
32
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
33
+	public function get_query(): EEM_Ticket
34
+	{
35
+		return EEM_Ticket::instance();
36
+	}
37
+
38
+
39
+	/**
40
+	 * Return an array of item IDs from the query
41
+	 *
42
+	 * @return array
43
+	 */
44
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45
+	public function get_ids(): array
46
+	{
47
+		$results = $this->query->get_col($this->query_args);
48
+
49
+		return ! empty($results) ? $results : [];
50
+	}
51
+
52
+
53
+	/**
54
+	 * Here, we map the args from the input, then we make sure that we're only querying
55
+	 * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
56
+	 * handle batch resolution of the posts.
57
+	 *
58
+	 * @return array
59
+	 * @throws EE_Error
60
+	 * @throws InvalidArgumentException
61
+	 * @throws ReflectionException
62
+	 * @throws InvalidDataTypeException
63
+	 * @throws InvalidInterfaceException
64
+	 */
65
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
66
+	public function get_query_args(): array
67
+	{
68
+		$where_params = ['TKT_deleted' => ['IN', [true, false]]];
69
+		$query_args   = [];
70
+
71
+		$query_args['limit'] = $this->getLimit();
72
+
73
+		// Avoid multiple entries by join.
74
+		$query_args['group_by'] = 'TKT_ID';
75
+
76
+		$query_args['default_where_conditions'] = 'minimum';
77
+
78
+		/**
79
+		 * Collect the input_fields and sanitize them to prepare them for sending to the Query
80
+		 */
81
+		$input_fields = [];
82
+		if (! empty($this->args['where'])) {
83
+			$input_fields = $this->sanitizeInputFields($this->args['where']);
84
+
85
+			// Use the proper operator.
86
+			if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) {
87
+				$input_fields['Datetime.DTT_ID'] = ['IN', $input_fields['Datetime.DTT_ID']];
88
+			}
89
+			if (! empty($input_fields['Datetime.EVT_ID']) && is_array($input_fields['Datetime.EVT_ID'])) {
90
+				$input_fields['Datetime.EVT_ID'] = ['IN', $input_fields['Datetime.EVT_ID']];
91
+			}
92
+		}
93
+
94
+		/**
95
+		 * Determine where we're at in the Graph and adjust the query context appropriately.
96
+		 */
97
+		if ($this->source instanceof EE_Datetime) {
98
+			$where_params['Datetime.DTT_ID'] = $this->source->ID();
99
+		}
100
+
101
+		/**
102
+		 * Merge the input_fields with the default query_args
103
+		 */
104
+		if (! empty($input_fields)) {
105
+			$where_params = array_merge($where_params, $input_fields);
106
+		}
107
+
108
+		[$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID');
109
+
110
+		$search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : '';
111
+
112
+		if (! empty($search)) {
113
+			// use OR operator to search in any of the fields
114
+			$where_params['OR'] = array(
115
+				'TKT_name'        => array('LIKE', '%' . $search . '%'),
116
+				'TKT_description' => array('LIKE', '%' . $search . '%'),
117
+			);
118
+		}
119
+
120
+		// If default tickets should be included.
121
+		if (! empty($this->args['where']['includeDefaultTickets'])) {
122
+			/**
123
+			 * We need to get each ticket that
124
+			 * - satisfies $where_params above
125
+			 * OR
126
+			 * - it's a default ticket
127
+			 */
128
+			$where_params = [
129
+				'OR' => [
130
+					// use extra OR instead of AND to avoid it getting overridden
131
+					'OR' => [
132
+						'AND' => [
133
+							'TKT_deleted'    => ['IN', [true, false]],
134
+							'TKT_is_default' => 1,
135
+						]
136
+					],
137
+					'AND' => $where_params,
138
+				],
139
+			];
140
+		}
141
+
142
+		$where_params = apply_filters(
143
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_where_params',
144
+			$where_params,
145
+			$this->source,
146
+			$this->args
147
+		);
148
+
149
+		$query_args[] = $where_params;
150
+
151
+		/**
152
+		 * Return the $query_args
153
+		 */
154
+		return apply_filters(
155
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_query_args',
156
+			$query_args,
157
+			$this->source,
158
+			$this->args
159
+		);
160
+	}
161
+
162
+
163
+	/**
164
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
165
+	 * friendly keys.
166
+	 *
167
+	 * @param array $where_args
168
+	 * @return array
169
+	 */
170
+	public function sanitizeInputFields(array $where_args): array
171
+	{
172
+		$arg_mapping = [
173
+			'event'        => 'Datetime.EVT_ID',
174
+			'eventIn'      => 'Datetime.EVT_ID',
175
+			'eventIdIn'    => 'Datetime.EVT_ID',
176
+			'eventId'      => 'Datetime.EVT_ID', // priority.
177
+			'datetime'     => 'Datetime.DTT_ID',
178
+			'datetimeIn'   => 'Datetime.DTT_ID',
179
+			'datetimeIdIn' => 'Datetime.DTT_ID',
180
+			'datetimeId'   => 'Datetime.DTT_ID', // priority.
181
+			'isDefault'    => 'TKT_is_default',
182
+			'isRequired'   => 'TKT_required',
183
+			'isTaxable'    => 'TKT_taxable',
184
+			'isTrashed'    => 'TKT_deleted',
185
+		];
186
+		return $this->sanitizeWhereArgsForInputFields(
187
+			$where_args,
188
+			$arg_mapping,
189
+			['datetime', 'datetimeIn', 'event', 'eventIn']
190
+		);
191
+	}
192 192
 }
Please login to merge, or discard this patch.
core/domain/services/admin/entities/DefaultPrices.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function create(EE_Base_Class $entity): array
69 69
     {
70
-        if (! $entity instanceof EE_Ticket) {
70
+        if ( ! $entity instanceof EE_Ticket) {
71 71
             throw new InvalidEntityException($entity, 'EE_Ticket');
72 72
         }
73 73
         $is_free                   = true;
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
             $has_base_price,
92 92
             $is_free
93 93
         );
94
-        if (! $has_base_price) {
94
+        if ( ! $has_base_price) {
95 95
             $new_base_price                            = $this->createNewBasePrice($entity);
96
-            $this->new_prices[ $new_base_price->ID() ] = $new_base_price;
96
+            $this->new_prices[$new_base_price->ID()] = $new_base_price;
97 97
         }
98 98
         $this->applyTaxes($entity, $is_free);
99 99
         $ticket_total = $entity->get_ticket_total_with_taxes(true);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     private function applyTaxes(EE_Ticket $ticket, bool $is_free)
115 115
     {
116
-        if (! $is_free && $ticket->taxable() && ! empty($this->taxes)) {
116
+        if ( ! $is_free && $ticket->taxable() && ! empty($this->taxes)) {
117 117
             foreach ($this->taxes as $tax) {
118 118
                 // assign taxes but don't duplicate them because they operate globally
119 119
                 $ticket->set_taxable(true);
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
             $is_base_price = $default_price_clone->is_base_price();
163 163
             // add this price to ticket if it is a regular price modifier, ie: NOT a base price,
164 164
             // OR if it IS a base price but this ticket does NOT already have a base price
165
-            if (! $is_base_price || ! $has_base_price) {
165
+            if ( ! $is_base_price || ! $has_base_price) {
166 166
                 $default_price_clone->set('PRC_ID', null);
167 167
                 $default_price_clone->set('PRC_is_default', false);
168 168
                 $default_price_clone->save();
169 169
                 $default_price_clone->_add_relation_to($ticket, 'Ticket');
170
-                $this->new_prices[ $default_price_clone->ID() ] = $default_price_clone;
170
+                $this->new_prices[$default_price_clone->ID()] = $default_price_clone;
171 171
                 // then recheck that a base price has been set so that we don't add another one
172 172
                 $has_base_price = $is_base_price ? true : $has_base_price;
173 173
             }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                 ],
193 193
             ]
194 194
         );
195
-        if (! $base_price_type instanceof EE_Price_Type) {
195
+        if ( ! $base_price_type instanceof EE_Price_Type) {
196 196
             throw new RuntimeException(
197 197
                 esc_html__(
198 198
                     'A valid base price type could not be retrieved from the database.',
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
         $default_prices = [];
220 220
         if (is_array($prices)) {
221 221
             foreach ($prices as $key => $price) {
222
-                if (! $price instanceof EE_Price) {
222
+                if ( ! $price instanceof EE_Price) {
223 223
                     throw new InvalidEntityException($price, 'EE_Price');
224 224
                 }
225 225
                 // grab any taxes but don't do anything just yet
226 226
                 if ($price->is_tax()) {
227
-                    $this->taxes[ $price->ID() ] = $price;
227
+                    $this->taxes[$price->ID()] = $price;
228 228
                     continue;
229 229
                 }
230
-                $default_prices[ $price->ID() ] = $price;
230
+                $default_prices[$price->ID()] = $price;
231 231
             }
232 232
         }
233 233
         return $default_prices;
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -24,223 +24,223 @@
 block discarded – undo
24 24
  */
25 25
 class DefaultPrices implements DefaultEntityGeneratorInterface
26 26
 {
27
-    /**
28
-     * @var EEM_Price
29
-     */
30
-    protected $price_model;
31
-
32
-    /**
33
-     * @var EEM_Price_Type
34
-     */
35
-    protected $price_type_model;
36
-
37
-    /**
38
-     * @var EE_Price[]
39
-     */
40
-    protected $new_prices = [];
41
-
42
-    /**
43
-     * @var EE_Price[]
44
-     */
45
-    protected $taxes = [];
46
-
47
-
48
-    /**
49
-     * @param EEM_Price      $price_model
50
-     * @param EEM_Price_Type $price_type_model
51
-     */
52
-    public function __construct(EEM_Price $price_model, EEM_Price_Type $price_type_model)
53
-    {
54
-        $this->price_model      = $price_model;
55
-        $this->price_type_model = $price_type_model;
56
-    }
57
-
58
-
59
-    /**
60
-     * @param EE_Ticket|EE_Base_Class $entity
61
-     * @return EE_Price[]
62
-     * @throws EE_Error
63
-     * @throws InvalidInterfaceException
64
-     * @throws ReflectionException
65
-     * @since 5.0.0.p
66
-     */
67
-    public function create(EE_Base_Class $entity): array
68
-    {
69
-        if (! $entity instanceof EE_Ticket) {
70
-            throw new InvalidEntityException($entity, 'EE_Ticket');
71
-        }
72
-        $is_free                   = true;
73
-        $has_base_price            = false;
74
-        $remove_existing_relations = true;
75
-        // first, let's get all of the default taxes for the site
76
-        $this->taxes = $this->price_model->getAllDefaultTaxes();
77
-        // then separate taxes from the other prices for the existing default ticket prices
78
-        $default_prices = $this->separateTaxesFromOtherPrices($entity->prices());
79
-        // but if that's empty, then let's get the default global prices
80
-        if (empty($default_prices)) {
81
-            $default_global_prices     = $this->price_model->get_all_default_prices();
82
-            $default_prices            = $this->separateTaxesFromOtherPrices($default_global_prices);
83
-            $remove_existing_relations = false;
84
-        }
85
-        // then clone and apply all of the default prices
86
-        [$has_base_price, $is_free] = $this->cloneDefaultPrices(
87
-            $entity,
88
-            $default_prices,
89
-            $remove_existing_relations,
90
-            $has_base_price,
91
-            $is_free
92
-        );
93
-        if (! $has_base_price) {
94
-            $new_base_price                            = $this->createNewBasePrice($entity);
95
-            $this->new_prices[ $new_base_price->ID() ] = $new_base_price;
96
-        }
97
-        $this->applyTaxes($entity, $is_free);
98
-        $ticket_total = $entity->get_ticket_total_with_taxes(true);
99
-        if ($ticket_total !== $entity->ticket_price()) {
100
-            $entity->set_price($ticket_total);
101
-            $entity->save();
102
-        }
103
-        return $this->new_prices;
104
-    }
105
-
106
-
107
-    /**
108
-     * @param EE_Ticket $ticket
109
-     * @param bool      $is_free
110
-     * @throws EE_Error
111
-     * @throws ReflectionException
112
-     */
113
-    private function applyTaxes(EE_Ticket $ticket, bool $is_free)
114
-    {
115
-        if (! $is_free && $ticket->taxable() && ! empty($this->taxes)) {
116
-            foreach ($this->taxes as $tax) {
117
-                // assign taxes but don't duplicate them because they operate globally
118
-                $ticket->set_taxable(true);
119
-                $tax->_add_relation_to($ticket, 'Ticket');
120
-            }
121
-        }
122
-    }
123
-
124
-
125
-    /**
126
-     * @param EE_Ticket  $ticket
127
-     * @param EE_Price[] $default_prices
128
-     * @param bool       $remove_existing_relations
129
-     * @param bool       $has_base_price
130
-     * @param bool       $is_free
131
-     * @return bool[]
132
-     * @throws EE_Error
133
-     * @throws ReflectionException
134
-     */
135
-    private function cloneDefaultPrices(
136
-        EE_Ticket $ticket,
137
-        array $default_prices,
138
-        bool $remove_existing_relations,
139
-        bool $has_base_price,
140
-        bool $is_free
141
-    ): array {
142
-        foreach ($default_prices as $default_price) {
143
-            // duplicate the default price so that it does not get mutated
144
-            $default_price_clone = clone $default_price;
145
-            if ($remove_existing_relations) {
146
-                $ticket->_remove_relation_to($default_price, 'Price');
147
-            }
148
-            if (
149
-                (
150
-                    // has non-zero base price
151
-                    $default_price_clone->is_base_price()
152
-                    && $default_price_clone->amount() > 0
153
-                )
154
-                || (
155
-                    // or has fixed amount surcharge
156
-                    $default_price_clone->is_surcharge()
157
-                    && ! $default_price_clone->is_percent()
158
-                )
159
-            ) {
160
-                $is_free = false;
161
-            }
162
-            $is_base_price = $default_price_clone->is_base_price();
163
-            // add this price to ticket if it is a regular price modifier, ie: NOT a base price,
164
-            // OR if it IS a base price but this ticket does NOT already have a base price
165
-            if (! $is_base_price || ! $has_base_price) {
166
-                $default_price_clone->set('PRC_ID', null);
167
-                $default_price_clone->set('PRC_is_default', false);
168
-
169
-                $order = $default_price_clone->get('PRC_order');
170
-
171
-                // enforce base price order to be 1 and 5 if the order is not set for a modifier
172
-                $order = $is_base_price ? 1 : $order;
173
-                $order = $order ?? 5;
174
-
175
-                $default_price_clone->set('PRC_order', $order);
176
-
177
-                $default_price_clone->save();
178
-                $default_price_clone->_add_relation_to($ticket, 'Ticket');
179
-                $this->new_prices[ $default_price_clone->ID() ] = $default_price_clone;
180
-                // then recheck that a base price has been set so that we don't add another one
181
-                $has_base_price = $is_base_price ? true : $has_base_price;
182
-            }
183
-        }
184
-        return [$has_base_price, $is_free];
185
-    }
186
-
187
-
188
-    /**
189
-     * @param EE_Ticket $ticket
190
-     * @return EE_Price
191
-     * @throws EE_Error
192
-     * @throws ReflectionException
193
-     */
194
-    private function createNewBasePrice(EE_Ticket $ticket): EE_Price
195
-    {
196
-        $new_base_price  = $this->price_model->get_new_price();
197
-        $base_price_type = $this->price_type_model->get_one(
198
-            [
199
-                [
200
-                    'PBT_ID' => EEM_Price_Type::base_type_base_price,
201
-                ],
202
-            ]
203
-        );
204
-        if (! $base_price_type instanceof EE_Price_Type) {
205
-            throw new RuntimeException(
206
-                esc_html__(
207
-                    'A valid base price type could not be retrieved from the database.',
208
-                    'event_espresso'
209
-                )
210
-            );
211
-        }
212
-        $new_base_price->set('PRT_ID', $base_price_type->ID());
213
-        // set base price order to 1
214
-        $new_base_price->set('PRC_order', 1);
215
-        $new_base_price->set('PRC_is_default', false);
216
-        $new_base_price->save();
217
-        $new_base_price->_add_relation_to($ticket, 'Ticket');
218
-        return $new_base_price;
219
-    }
220
-
221
-
222
-    /**
223
-     * @param array $prices
224
-     * @return array
225
-     * @throws EE_Error
226
-     * @throws ReflectionException
227
-     */
228
-    private function separateTaxesFromOtherPrices(array $prices = []): array
229
-    {
230
-        $default_prices = [];
231
-        if (is_array($prices)) {
232
-            foreach ($prices as $key => $price) {
233
-                if (! $price instanceof EE_Price) {
234
-                    throw new InvalidEntityException($price, 'EE_Price');
235
-                }
236
-                // grab any taxes but don't do anything just yet
237
-                if ($price->is_tax()) {
238
-                    $this->taxes[ $price->ID() ] = $price;
239
-                    continue;
240
-                }
241
-                $default_prices[ $price->ID() ] = $price;
242
-            }
243
-        }
244
-        return $default_prices;
245
-    }
27
+	/**
28
+	 * @var EEM_Price
29
+	 */
30
+	protected $price_model;
31
+
32
+	/**
33
+	 * @var EEM_Price_Type
34
+	 */
35
+	protected $price_type_model;
36
+
37
+	/**
38
+	 * @var EE_Price[]
39
+	 */
40
+	protected $new_prices = [];
41
+
42
+	/**
43
+	 * @var EE_Price[]
44
+	 */
45
+	protected $taxes = [];
46
+
47
+
48
+	/**
49
+	 * @param EEM_Price      $price_model
50
+	 * @param EEM_Price_Type $price_type_model
51
+	 */
52
+	public function __construct(EEM_Price $price_model, EEM_Price_Type $price_type_model)
53
+	{
54
+		$this->price_model      = $price_model;
55
+		$this->price_type_model = $price_type_model;
56
+	}
57
+
58
+
59
+	/**
60
+	 * @param EE_Ticket|EE_Base_Class $entity
61
+	 * @return EE_Price[]
62
+	 * @throws EE_Error
63
+	 * @throws InvalidInterfaceException
64
+	 * @throws ReflectionException
65
+	 * @since 5.0.0.p
66
+	 */
67
+	public function create(EE_Base_Class $entity): array
68
+	{
69
+		if (! $entity instanceof EE_Ticket) {
70
+			throw new InvalidEntityException($entity, 'EE_Ticket');
71
+		}
72
+		$is_free                   = true;
73
+		$has_base_price            = false;
74
+		$remove_existing_relations = true;
75
+		// first, let's get all of the default taxes for the site
76
+		$this->taxes = $this->price_model->getAllDefaultTaxes();
77
+		// then separate taxes from the other prices for the existing default ticket prices
78
+		$default_prices = $this->separateTaxesFromOtherPrices($entity->prices());
79
+		// but if that's empty, then let's get the default global prices
80
+		if (empty($default_prices)) {
81
+			$default_global_prices     = $this->price_model->get_all_default_prices();
82
+			$default_prices            = $this->separateTaxesFromOtherPrices($default_global_prices);
83
+			$remove_existing_relations = false;
84
+		}
85
+		// then clone and apply all of the default prices
86
+		[$has_base_price, $is_free] = $this->cloneDefaultPrices(
87
+			$entity,
88
+			$default_prices,
89
+			$remove_existing_relations,
90
+			$has_base_price,
91
+			$is_free
92
+		);
93
+		if (! $has_base_price) {
94
+			$new_base_price                            = $this->createNewBasePrice($entity);
95
+			$this->new_prices[ $new_base_price->ID() ] = $new_base_price;
96
+		}
97
+		$this->applyTaxes($entity, $is_free);
98
+		$ticket_total = $entity->get_ticket_total_with_taxes(true);
99
+		if ($ticket_total !== $entity->ticket_price()) {
100
+			$entity->set_price($ticket_total);
101
+			$entity->save();
102
+		}
103
+		return $this->new_prices;
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param EE_Ticket $ticket
109
+	 * @param bool      $is_free
110
+	 * @throws EE_Error
111
+	 * @throws ReflectionException
112
+	 */
113
+	private function applyTaxes(EE_Ticket $ticket, bool $is_free)
114
+	{
115
+		if (! $is_free && $ticket->taxable() && ! empty($this->taxes)) {
116
+			foreach ($this->taxes as $tax) {
117
+				// assign taxes but don't duplicate them because they operate globally
118
+				$ticket->set_taxable(true);
119
+				$tax->_add_relation_to($ticket, 'Ticket');
120
+			}
121
+		}
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param EE_Ticket  $ticket
127
+	 * @param EE_Price[] $default_prices
128
+	 * @param bool       $remove_existing_relations
129
+	 * @param bool       $has_base_price
130
+	 * @param bool       $is_free
131
+	 * @return bool[]
132
+	 * @throws EE_Error
133
+	 * @throws ReflectionException
134
+	 */
135
+	private function cloneDefaultPrices(
136
+		EE_Ticket $ticket,
137
+		array $default_prices,
138
+		bool $remove_existing_relations,
139
+		bool $has_base_price,
140
+		bool $is_free
141
+	): array {
142
+		foreach ($default_prices as $default_price) {
143
+			// duplicate the default price so that it does not get mutated
144
+			$default_price_clone = clone $default_price;
145
+			if ($remove_existing_relations) {
146
+				$ticket->_remove_relation_to($default_price, 'Price');
147
+			}
148
+			if (
149
+				(
150
+					// has non-zero base price
151
+					$default_price_clone->is_base_price()
152
+					&& $default_price_clone->amount() > 0
153
+				)
154
+				|| (
155
+					// or has fixed amount surcharge
156
+					$default_price_clone->is_surcharge()
157
+					&& ! $default_price_clone->is_percent()
158
+				)
159
+			) {
160
+				$is_free = false;
161
+			}
162
+			$is_base_price = $default_price_clone->is_base_price();
163
+			// add this price to ticket if it is a regular price modifier, ie: NOT a base price,
164
+			// OR if it IS a base price but this ticket does NOT already have a base price
165
+			if (! $is_base_price || ! $has_base_price) {
166
+				$default_price_clone->set('PRC_ID', null);
167
+				$default_price_clone->set('PRC_is_default', false);
168
+
169
+				$order = $default_price_clone->get('PRC_order');
170
+
171
+				// enforce base price order to be 1 and 5 if the order is not set for a modifier
172
+				$order = $is_base_price ? 1 : $order;
173
+				$order = $order ?? 5;
174
+
175
+				$default_price_clone->set('PRC_order', $order);
176
+
177
+				$default_price_clone->save();
178
+				$default_price_clone->_add_relation_to($ticket, 'Ticket');
179
+				$this->new_prices[ $default_price_clone->ID() ] = $default_price_clone;
180
+				// then recheck that a base price has been set so that we don't add another one
181
+				$has_base_price = $is_base_price ? true : $has_base_price;
182
+			}
183
+		}
184
+		return [$has_base_price, $is_free];
185
+	}
186
+
187
+
188
+	/**
189
+	 * @param EE_Ticket $ticket
190
+	 * @return EE_Price
191
+	 * @throws EE_Error
192
+	 * @throws ReflectionException
193
+	 */
194
+	private function createNewBasePrice(EE_Ticket $ticket): EE_Price
195
+	{
196
+		$new_base_price  = $this->price_model->get_new_price();
197
+		$base_price_type = $this->price_type_model->get_one(
198
+			[
199
+				[
200
+					'PBT_ID' => EEM_Price_Type::base_type_base_price,
201
+				],
202
+			]
203
+		);
204
+		if (! $base_price_type instanceof EE_Price_Type) {
205
+			throw new RuntimeException(
206
+				esc_html__(
207
+					'A valid base price type could not be retrieved from the database.',
208
+					'event_espresso'
209
+				)
210
+			);
211
+		}
212
+		$new_base_price->set('PRT_ID', $base_price_type->ID());
213
+		// set base price order to 1
214
+		$new_base_price->set('PRC_order', 1);
215
+		$new_base_price->set('PRC_is_default', false);
216
+		$new_base_price->save();
217
+		$new_base_price->_add_relation_to($ticket, 'Ticket');
218
+		return $new_base_price;
219
+	}
220
+
221
+
222
+	/**
223
+	 * @param array $prices
224
+	 * @return array
225
+	 * @throws EE_Error
226
+	 * @throws ReflectionException
227
+	 */
228
+	private function separateTaxesFromOtherPrices(array $prices = []): array
229
+	{
230
+		$default_prices = [];
231
+		if (is_array($prices)) {
232
+			foreach ($prices as $key => $price) {
233
+				if (! $price instanceof EE_Price) {
234
+					throw new InvalidEntityException($price, 'EE_Price');
235
+				}
236
+				// grab any taxes but don't do anything just yet
237
+				if ($price->is_tax()) {
238
+					$this->taxes[ $price->ID() ] = $price;
239
+					continue;
240
+				}
241
+				$default_prices[ $price->ID() ] = $price;
242
+			}
243
+		}
244
+		return $default_prices;
245
+	}
246 246
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -110,13 +110,13 @@
 block discarded – undo
110 110
             'WP_User'              => new EE_Belongs_To_Relation(),
111 111
         ];
112 112
         // this model is generally available for reading
113
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
113
+        $this->_cap_restriction_generators[EEM_Base::caps_read]       =
114 114
             new EE_Restriction_Generator_Public();
115
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
115
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] =
116 116
             new EE_Restriction_Generator_Reg_Form('QSG_system');
117
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
117
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]       =
118 118
             new EE_Restriction_Generator_Reg_Form('QSG_system');
119
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
119
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]     =
120 120
             new EE_Restriction_Generator_Reg_Form('QSG_system');
121 121
 
122 122
         parent::__construct($timezone);
Please login to merge, or discard this patch.
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -9,136 +9,136 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Question_Group extends EEM_Soft_Delete_Base
11 11
 {
12
-    const system_personal = 1;
12
+	const system_personal = 1;
13 13
 
14
-    const system_address = 2;
14
+	const system_address = 2;
15 15
 
16
-    /**
17
-     * private instance of the EEM_Question_Group object
18
-     *
19
-     * @var EEM_Question_Group
20
-     */
21
-    protected static $_instance = null;
16
+	/**
17
+	 * private instance of the EEM_Question_Group object
18
+	 *
19
+	 * @var EEM_Question_Group
20
+	 */
21
+	protected static $_instance = null;
22 22
 
23 23
 
24
-    /**
25
-     * EEM_Question_Group constructor.
26
-     *
27
-     * @param string|null $timezone
28
-     */
29
-    protected function __construct($timezone = null)
30
-    {
31
-        $this->singular_item = esc_html__('Question Group', 'event_espresso');
32
-        $this->plural_item   = esc_html__('Question Groups', 'event_espresso');
24
+	/**
25
+	 * EEM_Question_Group constructor.
26
+	 *
27
+	 * @param string|null $timezone
28
+	 */
29
+	protected function __construct($timezone = null)
30
+	{
31
+		$this->singular_item = esc_html__('Question Group', 'event_espresso');
32
+		$this->plural_item   = esc_html__('Question Groups', 'event_espresso');
33 33
 
34
-        $this->_tables          = [
35
-            'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID'),
36
-        ];
37
-        $this->_fields          = [
38
-            'Question_Group' => [
39
-                'QSG_ID'              => new EE_Primary_Key_Int_Field(
40
-                    'QSG_ID',
41
-                    esc_html__('Question Group ID', 'event_espresso')
42
-                ),
43
-                'QSG_deleted'         => new EE_Trashed_Flag_Field(
44
-                    'QSG_deleted',
45
-                    esc_html__('Flag indicating this question group was deleted', 'event_espresso'),
46
-                    false,
47
-                    false
48
-                ),
49
-                'QSG_desc'            => new EE_Post_Content_Field(
50
-                    'QSG_desc',
51
-                    esc_html__('Description of Question Group', 'event_espresso'),
52
-                    true,
53
-                    ''
54
-                ),
55
-                'QSG_identifier'      => new EE_Plain_Text_Field(
56
-                    'QSG_identifier',
57
-                    esc_html__('Text ID for question Group', 'event_espresso'),
58
-                    false,
59
-                    ''
60
-                ),
61
-                'QSG_name'            => new EE_Plain_Text_Field(
62
-                    'QSG_name',
63
-                    esc_html__('Question Group Name', 'event_espresso'),
64
-                    false,
65
-                    ''
66
-                ),
67
-                'QSG_order'           => new EE_Integer_Field(
68
-                    'QSG_order',
69
-                    esc_html__('Order in which to show the question group', 'event_espresso'),
70
-                    true,
71
-                    0
72
-                ),
73
-                'QSG_show_group_desc' => new EE_Boolean_Field(
74
-                    'QSG_show_group_desc',
75
-                    esc_html__(
76
-                        'Flag indicating whether to show the group\s description on the registration page',
77
-                        'event_espresso'
78
-                    ),
79
-                    false,
80
-                    false
81
-                ),
82
-                'QSG_show_group_name' => new EE_Boolean_Field(
83
-                    'QSG_show_group_name',
84
-                    esc_html__(
85
-                        'Flag indicating whether to show the group\'s name on the registration page',
86
-                        'event_espresso'
87
-                    ),
88
-                    false,
89
-                    true
90
-                ),
91
-                'QSG_system'          => new EE_Integer_Field(
92
-                    'QSG_system',
93
-                    esc_html__(
94
-                        'Indicate IF this is a system group and if it is what system group it corresponds to.',
95
-                        'event_espresso'
96
-                    ),
97
-                    false,
98
-                    0
99
-                ),
100
-                'QSG_wp_user'         => new EE_WP_User_Field(
101
-                    'QSG_wp_user',
102
-                    esc_html__('Question Group Creator ID', 'event_espresso'),
103
-                    false
104
-                ),
105
-            ],
106
-        ];
107
-        $this->_model_relations = [
108
-            'Event'                => new EE_HABTM_Relation('Event_Question_Group'),
109
-            'Event_Question_Group' => new EE_Has_Many_Relation(),
110
-            'Question'             => new EE_HABTM_Relation('Question_Group_Question'),
111
-            'WP_User'              => new EE_Belongs_To_Relation(),
112
-        ];
113
-        // this model is generally available for reading
114
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
115
-            new EE_Restriction_Generator_Public();
116
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
117
-            new EE_Restriction_Generator_Reg_Form('QSG_system');
118
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
119
-            new EE_Restriction_Generator_Reg_Form('QSG_system');
120
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
121
-            new EE_Restriction_Generator_Reg_Form('QSG_system');
34
+		$this->_tables          = [
35
+			'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID'),
36
+		];
37
+		$this->_fields          = [
38
+			'Question_Group' => [
39
+				'QSG_ID'              => new EE_Primary_Key_Int_Field(
40
+					'QSG_ID',
41
+					esc_html__('Question Group ID', 'event_espresso')
42
+				),
43
+				'QSG_deleted'         => new EE_Trashed_Flag_Field(
44
+					'QSG_deleted',
45
+					esc_html__('Flag indicating this question group was deleted', 'event_espresso'),
46
+					false,
47
+					false
48
+				),
49
+				'QSG_desc'            => new EE_Post_Content_Field(
50
+					'QSG_desc',
51
+					esc_html__('Description of Question Group', 'event_espresso'),
52
+					true,
53
+					''
54
+				),
55
+				'QSG_identifier'      => new EE_Plain_Text_Field(
56
+					'QSG_identifier',
57
+					esc_html__('Text ID for question Group', 'event_espresso'),
58
+					false,
59
+					''
60
+				),
61
+				'QSG_name'            => new EE_Plain_Text_Field(
62
+					'QSG_name',
63
+					esc_html__('Question Group Name', 'event_espresso'),
64
+					false,
65
+					''
66
+				),
67
+				'QSG_order'           => new EE_Integer_Field(
68
+					'QSG_order',
69
+					esc_html__('Order in which to show the question group', 'event_espresso'),
70
+					true,
71
+					0
72
+				),
73
+				'QSG_show_group_desc' => new EE_Boolean_Field(
74
+					'QSG_show_group_desc',
75
+					esc_html__(
76
+						'Flag indicating whether to show the group\s description on the registration page',
77
+						'event_espresso'
78
+					),
79
+					false,
80
+					false
81
+				),
82
+				'QSG_show_group_name' => new EE_Boolean_Field(
83
+					'QSG_show_group_name',
84
+					esc_html__(
85
+						'Flag indicating whether to show the group\'s name on the registration page',
86
+						'event_espresso'
87
+					),
88
+					false,
89
+					true
90
+				),
91
+				'QSG_system'          => new EE_Integer_Field(
92
+					'QSG_system',
93
+					esc_html__(
94
+						'Indicate IF this is a system group and if it is what system group it corresponds to.',
95
+						'event_espresso'
96
+					),
97
+					false,
98
+					0
99
+				),
100
+				'QSG_wp_user'         => new EE_WP_User_Field(
101
+					'QSG_wp_user',
102
+					esc_html__('Question Group Creator ID', 'event_espresso'),
103
+					false
104
+				),
105
+			],
106
+		];
107
+		$this->_model_relations = [
108
+			'Event'                => new EE_HABTM_Relation('Event_Question_Group'),
109
+			'Event_Question_Group' => new EE_Has_Many_Relation(),
110
+			'Question'             => new EE_HABTM_Relation('Question_Group_Question'),
111
+			'WP_User'              => new EE_Belongs_To_Relation(),
112
+		];
113
+		// this model is generally available for reading
114
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
115
+			new EE_Restriction_Generator_Public();
116
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
117
+			new EE_Restriction_Generator_Reg_Form('QSG_system');
118
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
119
+			new EE_Restriction_Generator_Reg_Form('QSG_system');
120
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
121
+			new EE_Restriction_Generator_Reg_Form('QSG_system');
122 122
 
123
-        parent::__construct($timezone);
124
-    }
123
+		parent::__construct($timezone);
124
+	}
125 125
 
126 126
 
127
-    /**
128
-     * searches the db for the question group with the latest question order and returns that value.
129
-     *
130
-     * @return int
131
-     * @throws EE_Error
132
-     */
133
-    public function get_latest_question_group_order(): int
134
-    {
135
-        $max = $this->_get_all_wpdb_results(
136
-            [],
137
-            ARRAY_A,
138
-            [
139
-                'max_order' => ["MAX(QSG_order)", "%d"],
140
-            ]
141
-        );
142
-        return $max[0]['max_order'];
143
-    }
127
+	/**
128
+	 * searches the db for the question group with the latest question order and returns that value.
129
+	 *
130
+	 * @return int
131
+	 * @throws EE_Error
132
+	 */
133
+	public function get_latest_question_group_order(): int
134
+	{
135
+		$max = $this->_get_all_wpdb_results(
136
+			[],
137
+			ARRAY_A,
138
+			[
139
+				'max_order' => ["MAX(QSG_order)", "%d"],
140
+			]
141
+		);
142
+		return $max[0]['max_order'];
143
+	}
144 144
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Option.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,13 +74,13 @@
 block discarded – undo
74 74
         $this->_model_chain_to_wp_user = 'Question';
75 75
 
76 76
         // this model is generally available for reading
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
77
+        $this->_cap_restriction_generators[EEM_Base::caps_read]       =
78 78
             new EE_Restriction_Generator_Public();
79
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
79
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] =
80 80
             new EE_Restriction_Generator_Reg_Form('QSO_system');
81
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
81
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]       =
82 82
             new EE_Restriction_Generator_Reg_Form('QSO_system');
83
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
83
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]     =
84 84
             new EE_Restriction_Generator_Reg_Form('QSO_system');
85 85
 
86 86
         parent::__construct($timezone);
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -9,80 +9,80 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Question_Option extends EEM_Soft_Delete_Base
11 11
 {
12
-    // private instance of the Attendee object
13
-    protected static $_instance = null;
12
+	// private instance of the Attendee object
13
+	protected static $_instance = null;
14 14
 
15 15
 
16
-    protected function __construct($timezone = null)
17
-    {
18
-        $this->singular_item = esc_html__('Question Option', 'event_espresso');
19
-        $this->plural_item   = esc_html__('Question Options', 'event_espresso');
16
+	protected function __construct($timezone = null)
17
+	{
18
+		$this->singular_item = esc_html__('Question Option', 'event_espresso');
19
+		$this->plural_item   = esc_html__('Question Options', 'event_espresso');
20 20
 
21
-        $this->_tables          = [
22
-            'Question_Option' => new EE_Primary_Table('esp_question_option', 'QSO_ID'),
23
-        ];
24
-        $this->_fields          = [
25
-            'Question_Option' => [
26
-                'QSO_ID'      => new EE_Primary_Key_Int_Field(
27
-                    'QSO_ID',
28
-                    esc_html__('Question Option ID', 'event_espresso')
29
-                ),
30
-                'QST_ID'      => new EE_Foreign_Key_Int_Field(
31
-                    'QST_ID',
32
-                    esc_html__('Question ID', 'event_espresso'),
33
-                    false,
34
-                    0,
35
-                    'Question'
36
-                ),
37
-                'QSO_deleted' => new EE_Trashed_Flag_Field(
38
-                    'QSO_deleted',
39
-                    esc_html__('Flag indicating Option was trashed', 'event_espresso'),
40
-                    false,
41
-                    false
42
-                ),
43
-                'QSO_desc'    => new EE_Post_Content_Field(
44
-                    'QSO_desc',
45
-                    esc_html__('Question Option Description', 'event_espresso'),
46
-                    false,
47
-                    ''
48
-                ),
49
-                'QSO_order'   => new EE_Integer_Field(
50
-                    'QSO_order',
51
-                    esc_html__('Question Option Order', 'event_espresso'),
52
-                    false,
53
-                    0
54
-                ),
55
-                'QSO_system'  => new EE_Plain_Text_Field(
56
-                    'QSO_system',
57
-                    esc_html__('Internal string ID for question option', 'event_espresso'),
58
-                    true,
59
-                    null
60
-                ),
61
-                'QSO_value'   => new EE_Plain_Text_Field(
62
-                    'QSO_value',
63
-                    esc_html__("Question Option Value", "event_espresso"),
64
-                    false,
65
-                    ''
66
-                ),
67
-            ],
68
-        ];
69
-        $this->_model_relations = [
70
-            'Question' => new EE_Belongs_To_Relation(),
71
-        ];
21
+		$this->_tables          = [
22
+			'Question_Option' => new EE_Primary_Table('esp_question_option', 'QSO_ID'),
23
+		];
24
+		$this->_fields          = [
25
+			'Question_Option' => [
26
+				'QSO_ID'      => new EE_Primary_Key_Int_Field(
27
+					'QSO_ID',
28
+					esc_html__('Question Option ID', 'event_espresso')
29
+				),
30
+				'QST_ID'      => new EE_Foreign_Key_Int_Field(
31
+					'QST_ID',
32
+					esc_html__('Question ID', 'event_espresso'),
33
+					false,
34
+					0,
35
+					'Question'
36
+				),
37
+				'QSO_deleted' => new EE_Trashed_Flag_Field(
38
+					'QSO_deleted',
39
+					esc_html__('Flag indicating Option was trashed', 'event_espresso'),
40
+					false,
41
+					false
42
+				),
43
+				'QSO_desc'    => new EE_Post_Content_Field(
44
+					'QSO_desc',
45
+					esc_html__('Question Option Description', 'event_espresso'),
46
+					false,
47
+					''
48
+				),
49
+				'QSO_order'   => new EE_Integer_Field(
50
+					'QSO_order',
51
+					esc_html__('Question Option Order', 'event_espresso'),
52
+					false,
53
+					0
54
+				),
55
+				'QSO_system'  => new EE_Plain_Text_Field(
56
+					'QSO_system',
57
+					esc_html__('Internal string ID for question option', 'event_espresso'),
58
+					true,
59
+					null
60
+				),
61
+				'QSO_value'   => new EE_Plain_Text_Field(
62
+					'QSO_value',
63
+					esc_html__("Question Option Value", "event_espresso"),
64
+					false,
65
+					''
66
+				),
67
+			],
68
+		];
69
+		$this->_model_relations = [
70
+			'Question' => new EE_Belongs_To_Relation(),
71
+		];
72 72
 
73
-        $this->_caps_slug              = 'questions';
74
-        $this->_model_chain_to_wp_user = 'Question';
73
+		$this->_caps_slug              = 'questions';
74
+		$this->_model_chain_to_wp_user = 'Question';
75 75
 
76
-        // this model is generally available for reading
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
78
-            new EE_Restriction_Generator_Public();
79
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
80
-            new EE_Restriction_Generator_Reg_Form('QSO_system');
81
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
82
-            new EE_Restriction_Generator_Reg_Form('QSO_system');
83
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
84
-            new EE_Restriction_Generator_Reg_Form('QSO_system');
76
+		// this model is generally available for reading
77
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
78
+			new EE_Restriction_Generator_Public();
79
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
80
+			new EE_Restriction_Generator_Reg_Form('QSO_system');
81
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
82
+			new EE_Restriction_Generator_Reg_Form('QSO_system');
83
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
84
+			new EE_Restriction_Generator_Reg_Form('QSO_system');
85 85
 
86
-        parent::__construct($timezone);
87
-    }
86
+		parent::__construct($timezone);
87
+	}
88 88
 }
Please login to merge, or discard this patch.