Completed
Branch EDTR/master (cec6bd)
by
unknown
17:56 queued 09:53
created
core/domain/services/graphql/types/Ticket.php 1 patch
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -25,285 +25,285 @@
 block discarded – undo
25 25
 class Ticket extends TypeBase
26 26
 {
27 27
 
28
-    /**
29
-     * Ticket constructor.
30
-     *
31
-     * @param EEM_Ticket $ticket_model
32
-     */
33
-    public function __construct(EEM_Ticket $ticket_model)
34
-    {
35
-        $this->model = $ticket_model;
36
-        $this->setName('Ticket');
37
-        $this->setDescription(__('A ticket for an event date', 'event_espresso'));
38
-        $this->setIsCustomPostType(false);
39
-        parent::__construct();
40
-    }
28
+	/**
29
+	 * Ticket constructor.
30
+	 *
31
+	 * @param EEM_Ticket $ticket_model
32
+	 */
33
+	public function __construct(EEM_Ticket $ticket_model)
34
+	{
35
+		$this->model = $ticket_model;
36
+		$this->setName('Ticket');
37
+		$this->setDescription(__('A ticket for an event date', 'event_espresso'));
38
+		$this->setIsCustomPostType(false);
39
+		parent::__construct();
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @return GraphQLFieldInterface[]
45
-     * @since $VID:$
46
-     */
47
-    public function getFields()
48
-    {
49
-        return [
50
-            new GraphQLField(
51
-                'id',
52
-                ['non_null' => 'ID'],
53
-                null,
54
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
55
-            ),
56
-            new GraphQLOutputField(
57
-                lcfirst($this->name()) . 'Id',
58
-                ['non_null' => 'Int'],
59
-                'ID',
60
-                esc_html__('Ticket ID', 'event_espresso')
61
-            ),
62
-            new GraphQLField(
63
-                'name',
64
-                'String',
65
-                'name',
66
-                esc_html__('Ticket Name', 'event_espresso')
67
-            ),
68
-            new GraphQLField(
69
-                'description',
70
-                'String',
71
-                'description',
72
-                esc_html__('Description of Ticket', 'event_espresso')
73
-            ),
74
-            new GraphQLField(
75
-                'startDate',
76
-                'String',
77
-                'start_date',
78
-                esc_html__('Start date and time of the Ticket', 'event_espresso'),
79
-                [$this, 'formatDatetime']
80
-            ),
81
-            new GraphQLField(
82
-                'endDate',
83
-                'String',
84
-                'end_date',
85
-                esc_html__('End date and time of the Ticket', 'event_espresso'),
86
-                [$this, 'formatDatetime']
87
-            ),
88
-            new GraphQLField(
89
-                'min',
90
-                'Int',
91
-                'min',
92
-                esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso')
93
-            ),
94
-            new GraphQLField(
95
-                'max',
96
-                'Int',
97
-                'max',
98
-                esc_html__(
99
-                    'Maximum quantity of this ticket that can be purchased in one transaction',
100
-                    'event_espresso'
101
-                ),
102
-                [$this, 'parseInfiniteValue']
103
-            ),
104
-            new GraphQLField(
105
-                'price',
106
-                'Float',
107
-                'price',
108
-                esc_html__('Final calculated price for ticket', 'event_espresso')
109
-            ),
110
-            new GraphQLField(
111
-                'sold',
112
-                'Int',
113
-                'sold',
114
-                esc_html__('Number of this ticket sold', 'event_espresso')
115
-            ),
116
-            new GraphQLField(
117
-                'quantity',
118
-                'Int',
119
-                'qty',
120
-                esc_html__('Quantity of this ticket that is available', 'event_espresso'),
121
-                [$this, 'parseInfiniteValue']
122
-            ),
123
-            new GraphQLField(
124
-                'reserved',
125
-                'Int',
126
-                'reserved',
127
-                esc_html__(
128
-                    'Quantity of this ticket that is reserved, but not yet fully purchased',
129
-                    'event_espresso'
130
-                )
131
-            ),
132
-            new GraphQLField(
133
-                'uses',
134
-                'Int',
135
-                'uses',
136
-                esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'),
137
-                [$this, 'parseInfiniteValue']
138
-            ),
139
-            new GraphQLField(
140
-                'isRequired',
141
-                'Boolean',
142
-                'required',
143
-                esc_html__(
144
-                    'Flag indicating whether this ticket must be purchased with a transaction',
145
-                    'event_espresso'
146
-                )
147
-            ),
148
-            new GraphQLField(
149
-                'isTaxable',
150
-                'Boolean',
151
-                'taxable',
152
-                esc_html__(
153
-                    'Flag indicating whether there is tax applied on this ticket',
154
-                    'event_espresso'
155
-                )
156
-            ),
157
-            new GraphQLField(
158
-                'isDefault',
159
-                'Boolean',
160
-                'is_default',
161
-                esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso')
162
-            ),
163
-            new GraphQLField(
164
-                'order',
165
-                'Int',
166
-                'order',
167
-                esc_html__('The order in which the Datetime is displayed', 'event_espresso')
168
-            ),
169
-            new GraphQLField(
170
-                'row',
171
-                'Int',
172
-                'row',
173
-                esc_html__('How tickets are displayed in the ui', 'event_espresso')
174
-            ),
175
-            new GraphQLOutputField(
176
-                'wpUser',
177
-                'User',
178
-                null,
179
-                esc_html__('Ticket Creator', 'event_espresso')
180
-            ),
181
-            new GraphQLInputField(
182
-                'wpUser',
183
-                'Int',
184
-                null,
185
-                esc_html__('Ticket Creator ID', 'event_espresso')
186
-            ),
187
-            new GraphQLOutputField(
188
-                'parent',
189
-                $this->name(),
190
-                null,
191
-                esc_html__('The parent ticket of the current ticket', 'event_espresso')
192
-            ),
193
-            new GraphQLInputField(
194
-                'parent',
195
-                'ID',
196
-                null,
197
-                esc_html__('The parent ticket ID', 'event_espresso')
198
-            ),
199
-            new GraphQLField(
200
-                'reverseCalculate',
201
-                'Boolean',
202
-                'reverse_calculate',
203
-                esc_html__(
204
-                    'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.',
205
-                    'event_espresso'
206
-                )
207
-            ),
208
-            new GraphQLField(
209
-                'isFree',
210
-                'Boolean',
211
-                'is_free',
212
-                esc_html__('Flag indicating whether the ticket is free.', 'event_espresso')
213
-            ),
214
-            new GraphQLOutputField(
215
-                'event',
216
-                'Event',
217
-                null,
218
-                esc_html__('Event of the ticket.', 'event_espresso')
219
-            ),
220
-            new GraphQLInputField(
221
-                'datetimes',
222
-                ['list_of' => 'ID'],
223
-                null,
224
-                sprintf(
225
-                    '%1$s %2$s',
226
-                    esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'),
227
-                    esc_html__('Ignored if empty.', 'event_espresso')
228
-                )
229
-            ),
230
-            new GraphQLInputField(
231
-                'prices',
232
-                ['list_of' => 'ID'],
233
-                null,
234
-                sprintf(
235
-                    '%1$s %2$s',
236
-                    esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'),
237
-                    esc_html__('Ignored if empty.', 'event_espresso')
238
-                )
239
-            ),
240
-        ];
241
-    }
43
+	/**
44
+	 * @return GraphQLFieldInterface[]
45
+	 * @since $VID:$
46
+	 */
47
+	public function getFields()
48
+	{
49
+		return [
50
+			new GraphQLField(
51
+				'id',
52
+				['non_null' => 'ID'],
53
+				null,
54
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
55
+			),
56
+			new GraphQLOutputField(
57
+				lcfirst($this->name()) . 'Id',
58
+				['non_null' => 'Int'],
59
+				'ID',
60
+				esc_html__('Ticket ID', 'event_espresso')
61
+			),
62
+			new GraphQLField(
63
+				'name',
64
+				'String',
65
+				'name',
66
+				esc_html__('Ticket Name', 'event_espresso')
67
+			),
68
+			new GraphQLField(
69
+				'description',
70
+				'String',
71
+				'description',
72
+				esc_html__('Description of Ticket', 'event_espresso')
73
+			),
74
+			new GraphQLField(
75
+				'startDate',
76
+				'String',
77
+				'start_date',
78
+				esc_html__('Start date and time of the Ticket', 'event_espresso'),
79
+				[$this, 'formatDatetime']
80
+			),
81
+			new GraphQLField(
82
+				'endDate',
83
+				'String',
84
+				'end_date',
85
+				esc_html__('End date and time of the Ticket', 'event_espresso'),
86
+				[$this, 'formatDatetime']
87
+			),
88
+			new GraphQLField(
89
+				'min',
90
+				'Int',
91
+				'min',
92
+				esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso')
93
+			),
94
+			new GraphQLField(
95
+				'max',
96
+				'Int',
97
+				'max',
98
+				esc_html__(
99
+					'Maximum quantity of this ticket that can be purchased in one transaction',
100
+					'event_espresso'
101
+				),
102
+				[$this, 'parseInfiniteValue']
103
+			),
104
+			new GraphQLField(
105
+				'price',
106
+				'Float',
107
+				'price',
108
+				esc_html__('Final calculated price for ticket', 'event_espresso')
109
+			),
110
+			new GraphQLField(
111
+				'sold',
112
+				'Int',
113
+				'sold',
114
+				esc_html__('Number of this ticket sold', 'event_espresso')
115
+			),
116
+			new GraphQLField(
117
+				'quantity',
118
+				'Int',
119
+				'qty',
120
+				esc_html__('Quantity of this ticket that is available', 'event_espresso'),
121
+				[$this, 'parseInfiniteValue']
122
+			),
123
+			new GraphQLField(
124
+				'reserved',
125
+				'Int',
126
+				'reserved',
127
+				esc_html__(
128
+					'Quantity of this ticket that is reserved, but not yet fully purchased',
129
+					'event_espresso'
130
+				)
131
+			),
132
+			new GraphQLField(
133
+				'uses',
134
+				'Int',
135
+				'uses',
136
+				esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'),
137
+				[$this, 'parseInfiniteValue']
138
+			),
139
+			new GraphQLField(
140
+				'isRequired',
141
+				'Boolean',
142
+				'required',
143
+				esc_html__(
144
+					'Flag indicating whether this ticket must be purchased with a transaction',
145
+					'event_espresso'
146
+				)
147
+			),
148
+			new GraphQLField(
149
+				'isTaxable',
150
+				'Boolean',
151
+				'taxable',
152
+				esc_html__(
153
+					'Flag indicating whether there is tax applied on this ticket',
154
+					'event_espresso'
155
+				)
156
+			),
157
+			new GraphQLField(
158
+				'isDefault',
159
+				'Boolean',
160
+				'is_default',
161
+				esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso')
162
+			),
163
+			new GraphQLField(
164
+				'order',
165
+				'Int',
166
+				'order',
167
+				esc_html__('The order in which the Datetime is displayed', 'event_espresso')
168
+			),
169
+			new GraphQLField(
170
+				'row',
171
+				'Int',
172
+				'row',
173
+				esc_html__('How tickets are displayed in the ui', 'event_espresso')
174
+			),
175
+			new GraphQLOutputField(
176
+				'wpUser',
177
+				'User',
178
+				null,
179
+				esc_html__('Ticket Creator', 'event_espresso')
180
+			),
181
+			new GraphQLInputField(
182
+				'wpUser',
183
+				'Int',
184
+				null,
185
+				esc_html__('Ticket Creator ID', 'event_espresso')
186
+			),
187
+			new GraphQLOutputField(
188
+				'parent',
189
+				$this->name(),
190
+				null,
191
+				esc_html__('The parent ticket of the current ticket', 'event_espresso')
192
+			),
193
+			new GraphQLInputField(
194
+				'parent',
195
+				'ID',
196
+				null,
197
+				esc_html__('The parent ticket ID', 'event_espresso')
198
+			),
199
+			new GraphQLField(
200
+				'reverseCalculate',
201
+				'Boolean',
202
+				'reverse_calculate',
203
+				esc_html__(
204
+					'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.',
205
+					'event_espresso'
206
+				)
207
+			),
208
+			new GraphQLField(
209
+				'isFree',
210
+				'Boolean',
211
+				'is_free',
212
+				esc_html__('Flag indicating whether the ticket is free.', 'event_espresso')
213
+			),
214
+			new GraphQLOutputField(
215
+				'event',
216
+				'Event',
217
+				null,
218
+				esc_html__('Event of the ticket.', 'event_espresso')
219
+			),
220
+			new GraphQLInputField(
221
+				'datetimes',
222
+				['list_of' => 'ID'],
223
+				null,
224
+				sprintf(
225
+					'%1$s %2$s',
226
+					esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'),
227
+					esc_html__('Ignored if empty.', 'event_espresso')
228
+				)
229
+			),
230
+			new GraphQLInputField(
231
+				'prices',
232
+				['list_of' => 'ID'],
233
+				null,
234
+				sprintf(
235
+					'%1$s %2$s',
236
+					esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'),
237
+					esc_html__('Ignored if empty.', 'event_espresso')
238
+				)
239
+			),
240
+		];
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     * @param array $inputFields The mutation input fields.
246
-     * @throws InvalidArgumentException
247
-     * @throws ReflectionException
248
-     * @since $VID:$
249
-     */
250
-    public function registerMutations(array $inputFields)
251
-    {
252
-        // Register mutation to update an entity.
253
-        register_graphql_mutation(
254
-            'update' . $this->name(),
255
-            [
256
-                'inputFields'         => $inputFields,
257
-                'outputFields'        => [
258
-                    lcfirst($this->name()) => [
259
-                        'type'    => $this->name(),
260
-                        'resolve' => [$this, 'resolveFromPayload'],
261
-                    ],
262
-                ],
263
-                'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this),
264
-            ]
265
-        );
266
-        // Register mutation to delete an entity.
267
-        register_graphql_mutation(
268
-            'delete' . $this->name(),
269
-            [
270
-                'inputFields'         => [
271
-                    'id'                => $inputFields['id'],
272
-                    'deletePermanently' => [
273
-                        'type'        => 'Boolean',
274
-                        'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
275
-                    ],
276
-                ],
277
-                'outputFields'        => [
278
-                    lcfirst($this->name()) => [
279
-                        'type'        => $this->name(),
280
-                        'description' => esc_html__('The object before it was deleted', 'event_espresso'),
281
-                        'resolve'     => static function ($payload) {
282
-                            $deleted = (object) $payload['deleted'];
244
+	/**
245
+	 * @param array $inputFields The mutation input fields.
246
+	 * @throws InvalidArgumentException
247
+	 * @throws ReflectionException
248
+	 * @since $VID:$
249
+	 */
250
+	public function registerMutations(array $inputFields)
251
+	{
252
+		// Register mutation to update an entity.
253
+		register_graphql_mutation(
254
+			'update' . $this->name(),
255
+			[
256
+				'inputFields'         => $inputFields,
257
+				'outputFields'        => [
258
+					lcfirst($this->name()) => [
259
+						'type'    => $this->name(),
260
+						'resolve' => [$this, 'resolveFromPayload'],
261
+					],
262
+				],
263
+				'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this),
264
+			]
265
+		);
266
+		// Register mutation to delete an entity.
267
+		register_graphql_mutation(
268
+			'delete' . $this->name(),
269
+			[
270
+				'inputFields'         => [
271
+					'id'                => $inputFields['id'],
272
+					'deletePermanently' => [
273
+						'type'        => 'Boolean',
274
+						'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
275
+					],
276
+				],
277
+				'outputFields'        => [
278
+					lcfirst($this->name()) => [
279
+						'type'        => $this->name(),
280
+						'description' => esc_html__('The object before it was deleted', 'event_espresso'),
281
+						'resolve'     => static function ($payload) {
282
+							$deleted = (object) $payload['deleted'];
283 283
 
284
-                            return ! empty($deleted) ? $deleted : null;
285
-                        },
286
-                    ],
287
-                ],
288
-                'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this),
289
-            ]
290
-        );
284
+							return ! empty($deleted) ? $deleted : null;
285
+						},
286
+					],
287
+				],
288
+				'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this),
289
+			]
290
+		);
291 291
 
292
-        // remove primary key from input.
293
-        unset($inputFields['id']);
294
-        // Register mutation to update an entity.
295
-        register_graphql_mutation(
296
-            'create' . $this->name(),
297
-            [
298
-                'inputFields'         => $inputFields,
299
-                'outputFields'        => [
300
-                    lcfirst($this->name()) => [
301
-                        'type'    => $this->name(),
302
-                        'resolve' => [$this, 'resolveFromPayload'],
303
-                    ],
304
-                ],
305
-                'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this),
306
-            ]
307
-        );
308
-    }
292
+		// remove primary key from input.
293
+		unset($inputFields['id']);
294
+		// Register mutation to update an entity.
295
+		register_graphql_mutation(
296
+			'create' . $this->name(),
297
+			[
298
+				'inputFields'         => $inputFields,
299
+				'outputFields'        => [
300
+					lcfirst($this->name()) => [
301
+						'type'    => $this->name(),
302
+						'resolve' => [$this, 'resolveFromPayload'],
303
+					],
304
+				],
305
+				'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this),
306
+			]
307
+		);
308
+	}
309 309
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/types/Datetime.php 1 patch
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -25,237 +25,237 @@
 block discarded – undo
25 25
 class Datetime extends TypeBase
26 26
 {
27 27
 
28
-    /**
29
-     * EventDate constructor.
30
-     *
31
-     * @param EEM_Datetime $datetime_model
32
-     */
33
-    public function __construct(EEM_Datetime $datetime_model)
34
-    {
35
-        $this->model = $datetime_model;
36
-        $this->setName('Datetime');
37
-        $this->setDescription(__('An event date', 'event_espresso'));
38
-        $this->setIsCustomPostType(false);
39
-        parent::__construct();
40
-    }
28
+	/**
29
+	 * EventDate constructor.
30
+	 *
31
+	 * @param EEM_Datetime $datetime_model
32
+	 */
33
+	public function __construct(EEM_Datetime $datetime_model)
34
+	{
35
+		$this->model = $datetime_model;
36
+		$this->setName('Datetime');
37
+		$this->setDescription(__('An event date', 'event_espresso'));
38
+		$this->setIsCustomPostType(false);
39
+		parent::__construct();
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @return GraphQLFieldInterface[]
45
-     * @since $VID:$
46
-     */
47
-    public function getFields()
48
-    {
49
-        return [
50
-            new GraphQLField(
51
-                'id',
52
-                ['non_null' => 'ID'],
53
-                null,
54
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
55
-            ),
56
-            new GraphQLOutputField(
57
-                lcfirst($this->name()) . 'Id',
58
-                ['non_null' => 'Int'],
59
-                'ID',
60
-                esc_html__('The datetime ID.', 'event_espresso')
61
-            ),
62
-            new GraphQLField(
63
-                'name',
64
-                'String',
65
-                'name',
66
-                esc_html__('Datetime Name', 'event_espresso')
67
-            ),
68
-            new GraphQLField(
69
-                'description',
70
-                'String',
71
-                'description',
72
-                esc_html__('Description for Datetime', 'event_espresso')
73
-            ),
74
-            new GraphQLField(
75
-                'startDate',
76
-                'String',
77
-                'start_date_and_time',
78
-                esc_html__('Start date and time of the Event', 'event_espresso'),
79
-                [$this, 'formatDatetime']
80
-            ),
81
-            new GraphQLField(
82
-                'endDate',
83
-                'String',
84
-                'end_date_and_time',
85
-                esc_html__('End date and time of the Event', 'event_espresso'),
86
-                [$this, 'formatDatetime']
87
-            ),
88
-            new GraphQLField(
89
-                'capacity',
90
-                'Int',
91
-                'reg_limit',
92
-                esc_html__('Registration Limit for this time', 'event_espresso'),
93
-                [$this, 'parseInfiniteValue']
94
-            ),
95
-            new GraphQLField(
96
-                'sold',
97
-                'Int',
98
-                'sold',
99
-                esc_html__('How many sales for this Datetime that have occurred', 'event_espresso')
100
-            ),
101
-            new GraphQLField(
102
-                'reserved',
103
-                'Int',
104
-                'reserved',
105
-                esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso')
106
-            ),
107
-            new GraphQLField(
108
-                'order',
109
-                'Int',
110
-                'order',
111
-                esc_html__('The order in which the Datetime is displayed', 'event_espresso')
112
-            ),
113
-            new GraphQLField(
114
-                'length',
115
-                'Int',
116
-                'length',
117
-                esc_html__('The length of the event (start to end time) in seconds', 'event_espresso')
118
-            ),
119
-            new GraphQLOutputField(
120
-                'parent',
121
-                $this->name(),
122
-                null,
123
-                esc_html__('The parent datetime of the current datetime', 'event_espresso')
124
-            ),
125
-            new GraphQLInputField(
126
-                'parent',
127
-                'ID',
128
-                null,
129
-                esc_html__('The parent datetime ID', 'event_espresso')
130
-            ),
131
-            new GraphQLField(
132
-                'isPrimary',
133
-                'Boolean',
134
-                'is_primary',
135
-                esc_html__('Flag indicating datetime is primary one for event', 'event_espresso')
136
-            ),
137
-            new GraphQLField(
138
-                'isSoldOut',
139
-                'Boolean',
140
-                'sold_out',
141
-                esc_html__(
142
-                    'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit',
143
-                    'event_espresso'
144
-                )
145
-            ),
146
-            new GraphQLField(
147
-                'isUpcoming',
148
-                'Boolean',
149
-                'is_upcoming',
150
-                esc_html__('Whether the date is upcoming', 'event_espresso')
151
-            ),
152
-            new GraphQLField(
153
-                'isActive',
154
-                'Boolean',
155
-                'is_active',
156
-                esc_html__('Flag indicating datetime is active', 'event_espresso')
157
-            ),
158
-            new GraphQLField(
159
-                'isExpired',
160
-                'Boolean',
161
-                'is_expired',
162
-                esc_html__('Flag indicating datetime is expired or not', 'event_espresso')
163
-            ),
164
-            new GraphQLOutputField(
165
-                'event',
166
-                'Event',
167
-                null,
168
-                esc_html__('Event of the datetime.', 'event_espresso')
169
-            ),
170
-            new GraphQLInputField(
171
-                'eventId',
172
-                'Int',
173
-                null,
174
-                esc_html__('Event ID of the datetime.', 'event_espresso')
175
-            ),
176
-            new GraphQLInputField(
177
-                'event',
178
-                'ID',
179
-                null,
180
-                esc_html__('Globally unique event ID of the datetime.', 'event_espresso')
181
-            ),
182
-            new GraphQLInputField(
183
-                'tickets',
184
-                ['list_of' => 'ID'],
185
-                null,
186
-                sprintf(
187
-                    '%1$s %2$s',
188
-                    esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'),
189
-                    esc_html__('Ignored if empty.', 'event_espresso')
190
-                )
191
-            ),
192
-        ];
193
-    }
43
+	/**
44
+	 * @return GraphQLFieldInterface[]
45
+	 * @since $VID:$
46
+	 */
47
+	public function getFields()
48
+	{
49
+		return [
50
+			new GraphQLField(
51
+				'id',
52
+				['non_null' => 'ID'],
53
+				null,
54
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
55
+			),
56
+			new GraphQLOutputField(
57
+				lcfirst($this->name()) . 'Id',
58
+				['non_null' => 'Int'],
59
+				'ID',
60
+				esc_html__('The datetime ID.', 'event_espresso')
61
+			),
62
+			new GraphQLField(
63
+				'name',
64
+				'String',
65
+				'name',
66
+				esc_html__('Datetime Name', 'event_espresso')
67
+			),
68
+			new GraphQLField(
69
+				'description',
70
+				'String',
71
+				'description',
72
+				esc_html__('Description for Datetime', 'event_espresso')
73
+			),
74
+			new GraphQLField(
75
+				'startDate',
76
+				'String',
77
+				'start_date_and_time',
78
+				esc_html__('Start date and time of the Event', 'event_espresso'),
79
+				[$this, 'formatDatetime']
80
+			),
81
+			new GraphQLField(
82
+				'endDate',
83
+				'String',
84
+				'end_date_and_time',
85
+				esc_html__('End date and time of the Event', 'event_espresso'),
86
+				[$this, 'formatDatetime']
87
+			),
88
+			new GraphQLField(
89
+				'capacity',
90
+				'Int',
91
+				'reg_limit',
92
+				esc_html__('Registration Limit for this time', 'event_espresso'),
93
+				[$this, 'parseInfiniteValue']
94
+			),
95
+			new GraphQLField(
96
+				'sold',
97
+				'Int',
98
+				'sold',
99
+				esc_html__('How many sales for this Datetime that have occurred', 'event_espresso')
100
+			),
101
+			new GraphQLField(
102
+				'reserved',
103
+				'Int',
104
+				'reserved',
105
+				esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso')
106
+			),
107
+			new GraphQLField(
108
+				'order',
109
+				'Int',
110
+				'order',
111
+				esc_html__('The order in which the Datetime is displayed', 'event_espresso')
112
+			),
113
+			new GraphQLField(
114
+				'length',
115
+				'Int',
116
+				'length',
117
+				esc_html__('The length of the event (start to end time) in seconds', 'event_espresso')
118
+			),
119
+			new GraphQLOutputField(
120
+				'parent',
121
+				$this->name(),
122
+				null,
123
+				esc_html__('The parent datetime of the current datetime', 'event_espresso')
124
+			),
125
+			new GraphQLInputField(
126
+				'parent',
127
+				'ID',
128
+				null,
129
+				esc_html__('The parent datetime ID', 'event_espresso')
130
+			),
131
+			new GraphQLField(
132
+				'isPrimary',
133
+				'Boolean',
134
+				'is_primary',
135
+				esc_html__('Flag indicating datetime is primary one for event', 'event_espresso')
136
+			),
137
+			new GraphQLField(
138
+				'isSoldOut',
139
+				'Boolean',
140
+				'sold_out',
141
+				esc_html__(
142
+					'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit',
143
+					'event_espresso'
144
+				)
145
+			),
146
+			new GraphQLField(
147
+				'isUpcoming',
148
+				'Boolean',
149
+				'is_upcoming',
150
+				esc_html__('Whether the date is upcoming', 'event_espresso')
151
+			),
152
+			new GraphQLField(
153
+				'isActive',
154
+				'Boolean',
155
+				'is_active',
156
+				esc_html__('Flag indicating datetime is active', 'event_espresso')
157
+			),
158
+			new GraphQLField(
159
+				'isExpired',
160
+				'Boolean',
161
+				'is_expired',
162
+				esc_html__('Flag indicating datetime is expired or not', 'event_espresso')
163
+			),
164
+			new GraphQLOutputField(
165
+				'event',
166
+				'Event',
167
+				null,
168
+				esc_html__('Event of the datetime.', 'event_espresso')
169
+			),
170
+			new GraphQLInputField(
171
+				'eventId',
172
+				'Int',
173
+				null,
174
+				esc_html__('Event ID of the datetime.', 'event_espresso')
175
+			),
176
+			new GraphQLInputField(
177
+				'event',
178
+				'ID',
179
+				null,
180
+				esc_html__('Globally unique event ID of the datetime.', 'event_espresso')
181
+			),
182
+			new GraphQLInputField(
183
+				'tickets',
184
+				['list_of' => 'ID'],
185
+				null,
186
+				sprintf(
187
+					'%1$s %2$s',
188
+					esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'),
189
+					esc_html__('Ignored if empty.', 'event_espresso')
190
+				)
191
+			),
192
+		];
193
+	}
194 194
 
195 195
 
196
-    /**
197
-     * @param array $inputFields The mutation input fields.
198
-     * @throws InvalidArgumentException
199
-     * @throws ReflectionException
200
-     * @since $VID:$
201
-     */
202
-    public function registerMutations(array $inputFields)
203
-    {
204
-        // Register mutation to update an entity.
205
-        register_graphql_mutation(
206
-            'update' . $this->name(),
207
-            [
208
-                'inputFields'         => $inputFields,
209
-                'outputFields'        => [
210
-                    lcfirst($this->name()) => [
211
-                        'type'    => $this->name(),
212
-                        'resolve' => [$this, 'resolveFromPayload'],
213
-                    ],
214
-                ],
215
-                'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
216
-            ]
217
-        );
218
-        // Register mutation to delete an entity.
219
-        register_graphql_mutation(
220
-            'delete' . $this->name(),
221
-            [
222
-                'inputFields'         => [
223
-                    'id'                => $inputFields['id'],
224
-                    'deletePermanently' => [
225
-                        'type'        => 'Boolean',
226
-                        'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
227
-                    ],
228
-                ],
229
-                'outputFields'        => [
230
-                    lcfirst($this->name()) => [
231
-                        'type'        => $this->name(),
232
-                        'description' => esc_html__('The object before it was deleted', 'event_espresso'),
233
-                        'resolve'     => static function ($payload) {
234
-                            $deleted = (object) $payload['deleted'];
196
+	/**
197
+	 * @param array $inputFields The mutation input fields.
198
+	 * @throws InvalidArgumentException
199
+	 * @throws ReflectionException
200
+	 * @since $VID:$
201
+	 */
202
+	public function registerMutations(array $inputFields)
203
+	{
204
+		// Register mutation to update an entity.
205
+		register_graphql_mutation(
206
+			'update' . $this->name(),
207
+			[
208
+				'inputFields'         => $inputFields,
209
+				'outputFields'        => [
210
+					lcfirst($this->name()) => [
211
+						'type'    => $this->name(),
212
+						'resolve' => [$this, 'resolveFromPayload'],
213
+					],
214
+				],
215
+				'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
216
+			]
217
+		);
218
+		// Register mutation to delete an entity.
219
+		register_graphql_mutation(
220
+			'delete' . $this->name(),
221
+			[
222
+				'inputFields'         => [
223
+					'id'                => $inputFields['id'],
224
+					'deletePermanently' => [
225
+						'type'        => 'Boolean',
226
+						'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
227
+					],
228
+				],
229
+				'outputFields'        => [
230
+					lcfirst($this->name()) => [
231
+						'type'        => $this->name(),
232
+						'description' => esc_html__('The object before it was deleted', 'event_espresso'),
233
+						'resolve'     => static function ($payload) {
234
+							$deleted = (object) $payload['deleted'];
235 235
 
236
-                            return ! empty($deleted) ? $deleted : null;
237
-                        },
238
-                    ],
239
-                ],
240
-                'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this),
241
-            ]
242
-        );
236
+							return ! empty($deleted) ? $deleted : null;
237
+						},
238
+					],
239
+				],
240
+				'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this),
241
+			]
242
+		);
243 243
 
244
-        // remove primary key from input.
245
-        unset($inputFields['id']);
246
-        // Register mutation to update an entity.
247
-        register_graphql_mutation(
248
-            'create' . $this->name(),
249
-            [
250
-                'inputFields'         => $inputFields,
251
-                'outputFields'        => [
252
-                    lcfirst($this->name()) => [
253
-                        'type'    => $this->name(),
254
-                        'resolve' => [$this, 'resolveFromPayload'],
255
-                    ],
256
-                ],
257
-                'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this),
258
-            ]
259
-        );
260
-    }
244
+		// remove primary key from input.
245
+		unset($inputFields['id']);
246
+		// Register mutation to update an entity.
247
+		register_graphql_mutation(
248
+			'create' . $this->name(),
249
+			[
250
+				'inputFields'         => $inputFields,
251
+				'outputFields'        => [
252
+					lcfirst($this->name()) => [
253
+						'type'    => $this->name(),
254
+						'resolve' => [$this, 'resolveFromPayload'],
255
+					],
256
+				],
257
+				'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this),
258
+			]
259
+		);
260
+	}
261 261
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/resolvers/FieldResolver.php 2 patches
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -39,221 +39,221 @@
 block discarded – undo
39 39
 class FieldResolver extends ResolverBase
40 40
 {
41 41
 
42
-    /**
43
-     * @var mixed $model
44
-     */
45
-    protected $model;
42
+	/**
43
+	 * @var mixed $model
44
+	 */
45
+	protected $model;
46 46
 
47
-    /**
48
-     * @var array $fields .
49
-     */
50
-    protected $fields;
47
+	/**
48
+	 * @var array $fields .
49
+	 */
50
+	protected $fields;
51 51
 
52 52
 
53
-    /**
54
-     * FieldResolver constructor.
55
-     *
56
-     * @param mixed $model  The model instance.
57
-     * @param array $fields The fields registered for the type.
58
-     */
59
-    public function __construct($model, array $fields)
60
-    {
61
-        $this->model = $model;
62
-        $this->fields = $fields;
63
-    }
53
+	/**
54
+	 * FieldResolver constructor.
55
+	 *
56
+	 * @param mixed $model  The model instance.
57
+	 * @param array $fields The fields registered for the type.
58
+	 */
59
+	public function __construct($model, array $fields)
60
+	{
61
+		$this->model = $model;
62
+		$this->fields = $fields;
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * @param mixed       $source  The source that's passed down the GraphQL queries
68
-     * @param array       $args    The inputArgs on the field
69
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
70
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
71
-     * @return string
72
-     * @throws EE_Error
73
-     * @throws Exception
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws ReflectionException
78
-     * @throws UserError
79
-     * @throws UnexpectedEntityException
80
-     * @since $VID:$
81
-     */
82
-    public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
83
-    {
84
-        $fieldName = $info->fieldName;
85
-        $field = isset($this->fields[ $fieldName ]) ? $this->fields[ $fieldName ] : null;
86
-        // Field should exist in teh registered fields
87
-        if ($field instanceof GraphQLField) {
88
-            // check if the field should be resolved.
89
-            if (! $field->shouldResolve()) {
90
-                return null;
91
-            }
92
-            // Give priority to the internal resolver.
93
-            if ($field->hasInternalResolver()) {
94
-                return $field->resolve($source, $args, $context, $info);
95
-            }
96
-            if (! ($source instanceof EE_Base_Class)) {
97
-                return null;
98
-            }
99
-            // Check if the field has a key mapped to model.
100
-            if (! empty($field->key())) {
101
-                $value = $source->{$field->key()}();
102
-                return $field->mayBeFormatValue($value, $source);
103
-            }
104
-            switch ($fieldName) {
105
-                case 'id': // the global ID
106
-                    return $this->resolveId($source);
107
-                case 'parent':
108
-                    return $this->resolveParent($source);
109
-                case 'event':
110
-                    return $this->resolveEvent($source, $args, $context);
111
-                case 'wpUser':
112
-                    return $this->resolveWpUser($source, $args, $context);
113
-                case 'state': // Venue
114
-                    return $this->resolveState($source);
115
-                case 'country': // State, Venue
116
-                    return $this->resolveCountry($source);
117
-            }
118
-        }
119
-        return null;
120
-    }
66
+	/**
67
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
68
+	 * @param array       $args    The inputArgs on the field
69
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
70
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
71
+	 * @return string
72
+	 * @throws EE_Error
73
+	 * @throws Exception
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws ReflectionException
78
+	 * @throws UserError
79
+	 * @throws UnexpectedEntityException
80
+	 * @since $VID:$
81
+	 */
82
+	public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
83
+	{
84
+		$fieldName = $info->fieldName;
85
+		$field = isset($this->fields[ $fieldName ]) ? $this->fields[ $fieldName ] : null;
86
+		// Field should exist in teh registered fields
87
+		if ($field instanceof GraphQLField) {
88
+			// check if the field should be resolved.
89
+			if (! $field->shouldResolve()) {
90
+				return null;
91
+			}
92
+			// Give priority to the internal resolver.
93
+			if ($field->hasInternalResolver()) {
94
+				return $field->resolve($source, $args, $context, $info);
95
+			}
96
+			if (! ($source instanceof EE_Base_Class)) {
97
+				return null;
98
+			}
99
+			// Check if the field has a key mapped to model.
100
+			if (! empty($field->key())) {
101
+				$value = $source->{$field->key()}();
102
+				return $field->mayBeFormatValue($value, $source);
103
+			}
104
+			switch ($fieldName) {
105
+				case 'id': // the global ID
106
+					return $this->resolveId($source);
107
+				case 'parent':
108
+					return $this->resolveParent($source);
109
+				case 'event':
110
+					return $this->resolveEvent($source, $args, $context);
111
+				case 'wpUser':
112
+					return $this->resolveWpUser($source, $args, $context);
113
+				case 'state': // Venue
114
+					return $this->resolveState($source);
115
+				case 'country': // State, Venue
116
+					return $this->resolveCountry($source);
117
+			}
118
+		}
119
+		return null;
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * Resolve the global ID
125
-     *
126
-     * @param mixed     $source
127
-     * @return string|null
128
-     * @throws Exception
129
-     * @since $VID:$
130
-     */
131
-    public function resolveId($source)
132
-    {
133
-        $ID = $source instanceof EE_Base_Class ? $source->ID() : 0;
123
+	/**
124
+	 * Resolve the global ID
125
+	 *
126
+	 * @param mixed     $source
127
+	 * @return string|null
128
+	 * @throws Exception
129
+	 * @since $VID:$
130
+	 */
131
+	public function resolveId($source)
132
+	{
133
+		$ID = $source instanceof EE_Base_Class ? $source->ID() : 0;
134 134
 
135
-        return $ID ? Relay::toGlobalId($this->model->item_name(), $ID) : null;
136
-    }
135
+		return $ID ? Relay::toGlobalId($this->model->item_name(), $ID) : null;
136
+	}
137 137
 
138 138
 
139
-    /**
140
-     * @param mixed     $source
141
-     * @param           $args
142
-     * @param           $context
143
-     * @return Deferred|null
144
-     * @throws Exception
145
-     * @since $VID:$
146
-     */
147
-    public function resolveWpUser($source, $args, $context)
148
-    {
149
-        $user_id = $source->wp_user();
150
-        return $user_id
151
-            ? DataSource::resolve_user($user_id, $context)
152
-            : null;
153
-    }
139
+	/**
140
+	 * @param mixed     $source
141
+	 * @param           $args
142
+	 * @param           $context
143
+	 * @return Deferred|null
144
+	 * @throws Exception
145
+	 * @since $VID:$
146
+	 */
147
+	public function resolveWpUser($source, $args, $context)
148
+	{
149
+		$user_id = $source->wp_user();
150
+		return $user_id
151
+			? DataSource::resolve_user($user_id, $context)
152
+			: null;
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * @param mixed $source
158
-     * @return EE_Base_Class|null
159
-     * @throws EE_Error
160
-     * @throws InvalidArgumentException
161
-     * @throws InvalidDataTypeException
162
-     * @throws InvalidInterfaceException
163
-     * @throws ReflectionException
164
-     * @since $VID:$
165
-     */
166
-    public function resolveParent($source)
167
-    {
168
-        return $this->model->get_one_by_ID($source->parent());
169
-    }
156
+	/**
157
+	 * @param mixed $source
158
+	 * @return EE_Base_Class|null
159
+	 * @throws EE_Error
160
+	 * @throws InvalidArgumentException
161
+	 * @throws InvalidDataTypeException
162
+	 * @throws InvalidInterfaceException
163
+	 * @throws ReflectionException
164
+	 * @since $VID:$
165
+	 */
166
+	public function resolveParent($source)
167
+	{
168
+		return $this->model->get_one_by_ID($source->parent());
169
+	}
170 170
 
171 171
 
172
-    /**
173
-     * @param mixed       $source
174
-     * @param             $args
175
-     * @param             $context
176
-     * @return Deferred|null
177
-     * @throws EE_Error
178
-     * @throws InvalidArgumentException
179
-     * @throws InvalidDataTypeException
180
-     * @throws InvalidInterfaceException
181
-     * @throws ReflectionException
182
-     * @throws UserError
183
-     * @throws UnexpectedEntityException
184
-     * @since $VID:$
185
-     */
186
-    public function resolveEvent($source, $args, $context)
187
-    {
188
-        switch (true) {
189
-            case $source instanceof EE_Datetime:
190
-                $event = $source->event();
191
-                break;
192
-            case $source instanceof EE_Venue:
193
-            case $source instanceof EE_Ticket:
194
-                $event = $source->get_related_event();
195
-                break;
196
-            default:
197
-                $event = null;
198
-                break;
199
-        }
200
-        return $event instanceof EE_Event
201
-            ? DataSource::resolve_post_object($event->ID(), $context)
202
-            : null;
203
-    }
172
+	/**
173
+	 * @param mixed       $source
174
+	 * @param             $args
175
+	 * @param             $context
176
+	 * @return Deferred|null
177
+	 * @throws EE_Error
178
+	 * @throws InvalidArgumentException
179
+	 * @throws InvalidDataTypeException
180
+	 * @throws InvalidInterfaceException
181
+	 * @throws ReflectionException
182
+	 * @throws UserError
183
+	 * @throws UnexpectedEntityException
184
+	 * @since $VID:$
185
+	 */
186
+	public function resolveEvent($source, $args, $context)
187
+	{
188
+		switch (true) {
189
+			case $source instanceof EE_Datetime:
190
+				$event = $source->event();
191
+				break;
192
+			case $source instanceof EE_Venue:
193
+			case $source instanceof EE_Ticket:
194
+				$event = $source->get_related_event();
195
+				break;
196
+			default:
197
+				$event = null;
198
+				break;
199
+		}
200
+		return $event instanceof EE_Event
201
+			? DataSource::resolve_post_object($event->ID(), $context)
202
+			: null;
203
+	}
204 204
 
205 205
 
206
-    /**
207
-     * @param mixed $source The source instance.
208
-     * @return EE_Base_Class|null
209
-     * @throws EE_Error
210
-     * @throws InvalidArgumentException
211
-     * @throws InvalidDataTypeException
212
-     * @throws InvalidInterfaceException
213
-     * @since $VID:$
214
-     */
215
-    public function resolveState($source)
216
-    {
217
-        switch (true) {
218
-            case $source instanceof EE_Attendee:
219
-            case $source instanceof EE_Venue:
220
-                $state_id = $source->state_ID();
221
-                break;
222
-            default:
223
-                $state_id = null;
224
-                break;
225
-        }
226
-        return $state_id
227
-            ? EEM_State::instance()->get_one_by_ID($state_id)
228
-            : null;
229
-    }
206
+	/**
207
+	 * @param mixed $source The source instance.
208
+	 * @return EE_Base_Class|null
209
+	 * @throws EE_Error
210
+	 * @throws InvalidArgumentException
211
+	 * @throws InvalidDataTypeException
212
+	 * @throws InvalidInterfaceException
213
+	 * @since $VID:$
214
+	 */
215
+	public function resolveState($source)
216
+	{
217
+		switch (true) {
218
+			case $source instanceof EE_Attendee:
219
+			case $source instanceof EE_Venue:
220
+				$state_id = $source->state_ID();
221
+				break;
222
+			default:
223
+				$state_id = null;
224
+				break;
225
+		}
226
+		return $state_id
227
+			? EEM_State::instance()->get_one_by_ID($state_id)
228
+			: null;
229
+	}
230 230
 
231 231
 
232
-    /**
233
-     * @param mixed $source The source instance.
234
-     * @return EE_Base_Class|null
235
-     * @throws EE_Error
236
-     * @throws InvalidArgumentException
237
-     * @throws InvalidDataTypeException
238
-     * @throws InvalidInterfaceException
239
-     * @since $VID:$
240
-     */
241
-    public function resolveCountry($source)
242
-    {
243
-        switch (true) {
244
-            case $source instanceof EE_State:
245
-                $country_iso = $source->country_iso();
246
-                break;
247
-            case $source instanceof EE_Venue:
248
-                $country_iso = $source->country_ID();
249
-                break;
250
-            default:
251
-                $country_iso = null;
252
-                break;
253
-        }
232
+	/**
233
+	 * @param mixed $source The source instance.
234
+	 * @return EE_Base_Class|null
235
+	 * @throws EE_Error
236
+	 * @throws InvalidArgumentException
237
+	 * @throws InvalidDataTypeException
238
+	 * @throws InvalidInterfaceException
239
+	 * @since $VID:$
240
+	 */
241
+	public function resolveCountry($source)
242
+	{
243
+		switch (true) {
244
+			case $source instanceof EE_State:
245
+				$country_iso = $source->country_iso();
246
+				break;
247
+			case $source instanceof EE_Venue:
248
+				$country_iso = $source->country_ID();
249
+				break;
250
+			default:
251
+				$country_iso = null;
252
+				break;
253
+		}
254 254
 
255
-        return $country_iso
256
-            ? EEM_Country::instance()->get_one_by_ID($country_iso)
257
-            : null;
258
-    }
255
+		return $country_iso
256
+			? EEM_Country::instance()->get_one_by_ID($country_iso)
257
+			: null;
258
+	}
259 259
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,22 +82,22 @@
 block discarded – undo
82 82
     public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
83 83
     {
84 84
         $fieldName = $info->fieldName;
85
-        $field = isset($this->fields[ $fieldName ]) ? $this->fields[ $fieldName ] : null;
85
+        $field = isset($this->fields[$fieldName]) ? $this->fields[$fieldName] : null;
86 86
         // Field should exist in teh registered fields
87 87
         if ($field instanceof GraphQLField) {
88 88
             // check if the field should be resolved.
89
-            if (! $field->shouldResolve()) {
89
+            if ( ! $field->shouldResolve()) {
90 90
                 return null;
91 91
             }
92 92
             // Give priority to the internal resolver.
93 93
             if ($field->hasInternalResolver()) {
94 94
                 return $field->resolve($source, $args, $context, $info);
95 95
             }
96
-            if (! ($source instanceof EE_Base_Class)) {
96
+            if ( ! ($source instanceof EE_Base_Class)) {
97 97
                 return null;
98 98
             }
99 99
             // Check if the field has a key mapped to model.
100
-            if (! empty($field->key())) {
100
+            if ( ! empty($field->key())) {
101 101
                 $value = $source->{$field->key()}();
102 102
                 return $field->mayBeFormatValue($value, $source);
103 103
             }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/DatetimeMutation.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -20,75 +20,75 @@
 block discarded – undo
20 20
 class DatetimeMutation
21 21
 {
22 22
 
23
-    /**
24
-     * Maps the GraphQL input to a format that the model functions can use
25
-     *
26
-     * @param array $input Data coming from the GraphQL mutation query input
27
-     * @return array
28
-     */
29
-    public static function prepareFields(array $input)
30
-    {
31
-
32
-        $args = [];
33
-
34
-        if (! empty($input['eventId'])) {
35
-            $args['EVT_ID'] = absint($input['eventId']);
36
-        } elseif (! empty($input['event'])) {
37
-            $parts = Relay::fromGlobalId($input['event']);
38
-            $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
39
-        }
40
-
41
-        if (! empty($input['name'])) {
42
-            $args['DTT_name'] = sanitize_text_field($input['name']);
43
-        }
44
-
45
-        if (! empty($input['description'])) {
46
-            $args['DTT_description'] = sanitize_text_field($input['description']);
47
-        }
48
-
49
-        if (! empty($input['startDate'])) {
50
-            $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate']));
51
-        }
52
-
53
-        if (! empty($input['endDate'])) {
54
-            $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate']));
55
-        }
56
-
57
-        if (! empty($input['tickets'])) {
58
-            $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']);
59
-        }
60
-
61
-        // Likewise the other fields...
62
-
63
-        return $args;
64
-    }
65
-
66
-
67
-    /**
68
-     * Sets the related tickets for the given datetime.
69
-     *
70
-     * @param EE_Datetime $entity  The datetime instance.
71
-     * @param array       $tickets Array of ticket IDs to relate.
72
-     * @throws EE_Error
73
-     * @throws InvalidDataTypeException
74
-     * @throws InvalidInterfaceException
75
-     * @throws InvalidArgumentException
76
-     * @throws ReflectionException
77
-     */
78
-    public static function setRelatedTickets($entity, array $tickets)
79
-    {
80
-        $relationName = 'Ticket';
81
-        // Remove all the existing related tickets
82
-        $entity->_remove_relations($relationName);
83
-
84
-        foreach ($tickets as $ID) {
85
-            $parts = Relay::fromGlobalId($ID);
86
-            if (! empty($parts['id']) && absint($parts['id'])) {
87
-                $entity->_add_relation_to(
88
-                    $parts['id'],
89
-                    $relationName
90
-                );
91
-            }
92
-        }
93
-    }
23
+	/**
24
+	 * Maps the GraphQL input to a format that the model functions can use
25
+	 *
26
+	 * @param array $input Data coming from the GraphQL mutation query input
27
+	 * @return array
28
+	 */
29
+	public static function prepareFields(array $input)
30
+	{
31
+
32
+		$args = [];
33
+
34
+		if (! empty($input['eventId'])) {
35
+			$args['EVT_ID'] = absint($input['eventId']);
36
+		} elseif (! empty($input['event'])) {
37
+			$parts = Relay::fromGlobalId($input['event']);
38
+			$args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
39
+		}
40
+
41
+		if (! empty($input['name'])) {
42
+			$args['DTT_name'] = sanitize_text_field($input['name']);
43
+		}
44
+
45
+		if (! empty($input['description'])) {
46
+			$args['DTT_description'] = sanitize_text_field($input['description']);
47
+		}
48
+
49
+		if (! empty($input['startDate'])) {
50
+			$args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate']));
51
+		}
52
+
53
+		if (! empty($input['endDate'])) {
54
+			$args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate']));
55
+		}
56
+
57
+		if (! empty($input['tickets'])) {
58
+			$args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']);
59
+		}
60
+
61
+		// Likewise the other fields...
62
+
63
+		return $args;
64
+	}
65
+
66
+
67
+	/**
68
+	 * Sets the related tickets for the given datetime.
69
+	 *
70
+	 * @param EE_Datetime $entity  The datetime instance.
71
+	 * @param array       $tickets Array of ticket IDs to relate.
72
+	 * @throws EE_Error
73
+	 * @throws InvalidDataTypeException
74
+	 * @throws InvalidInterfaceException
75
+	 * @throws InvalidArgumentException
76
+	 * @throws ReflectionException
77
+	 */
78
+	public static function setRelatedTickets($entity, array $tickets)
79
+	{
80
+		$relationName = 'Ticket';
81
+		// Remove all the existing related tickets
82
+		$entity->_remove_relations($relationName);
83
+
84
+		foreach ($tickets as $ID) {
85
+			$parts = Relay::fromGlobalId($ID);
86
+			if (! empty($parts['id']) && absint($parts['id'])) {
87
+				$entity->_add_relation_to(
88
+					$parts['id'],
89
+					$relationName
90
+				);
91
+			}
92
+		}
93
+	}
94 94
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
 
32 32
         $args = [];
33 33
 
34
-        if (! empty($input['eventId'])) {
34
+        if ( ! empty($input['eventId'])) {
35 35
             $args['EVT_ID'] = absint($input['eventId']);
36
-        } elseif (! empty($input['event'])) {
36
+        } elseif ( ! empty($input['event'])) {
37 37
             $parts = Relay::fromGlobalId($input['event']);
38
-            $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
38
+            $args['EVT_ID'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
39 39
         }
40 40
 
41
-        if (! empty($input['name'])) {
41
+        if ( ! empty($input['name'])) {
42 42
             $args['DTT_name'] = sanitize_text_field($input['name']);
43 43
         }
44 44
 
45
-        if (! empty($input['description'])) {
45
+        if ( ! empty($input['description'])) {
46 46
             $args['DTT_description'] = sanitize_text_field($input['description']);
47 47
         }
48 48
 
49
-        if (! empty($input['startDate'])) {
49
+        if ( ! empty($input['startDate'])) {
50 50
             $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate']));
51 51
         }
52 52
 
53
-        if (! empty($input['endDate'])) {
53
+        if ( ! empty($input['endDate'])) {
54 54
             $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate']));
55 55
         }
56 56
 
57
-        if (! empty($input['tickets'])) {
57
+        if ( ! empty($input['tickets'])) {
58 58
             $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']);
59 59
         }
60 60
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
         foreach ($tickets as $ID) {
85 85
             $parts = Relay::fromGlobalId($ID);
86
-            if (! empty($parts['id']) && absint($parts['id'])) {
86
+            if ( ! empty($parts['id']) && absint($parts['id'])) {
87 87
                 $entity->_add_relation_to(
88 88
                     $parts['id'],
89 89
                     $relationName
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/TicketMutation.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -14,95 +14,95 @@
 block discarded – undo
14 14
 class TicketMutation
15 15
 {
16 16
 
17
-    /**
18
-     * Maps the GraphQL input to a format that the model functions can use
19
-     *
20
-     * @param array $input Data coming from the GraphQL mutation query input
21
-     * @return array
22
-     */
23
-    public static function prepareFields(array $input)
24
-    {
25
-
26
-        $args = [];
27
-
28
-        if (! empty($input['name'])) {
29
-            $args['TKT_name'] = sanitize_text_field($input['name']);
30
-        }
31
-
32
-        if (! empty($input['description'])) {
33
-            $args['TKT_description'] = sanitize_text_field($input['description']);
34
-        }
35
-
36
-        if (! empty($input['price'])) {
37
-            $args['TKT_price'] = floatval($input['price']);
38
-        }
39
-
40
-        if (! empty($input['startDate'])) {
41
-            $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
42
-        }
43
-
44
-        if (! empty($input['endDate'])) {
45
-            $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
46
-        }
47
-
48
-        if (! empty($input['datetimes'])) {
49
-            $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
50
-        }
51
-
52
-        if (! empty($input['prices'])) {
53
-            $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']);
54
-        }
55
-
56
-        // Likewise the other fields...
57
-
58
-        return $args;
59
-    }
60
-
61
-    /**
62
-     * Sets the related datetimes for the given ticket.
63
-     *
64
-     * @param EE_Ticket $entity    The Ticket instance.
65
-     * @param array     $datetimes Array of datetime IDs to relate.
66
-     */
67
-    public static function setRelatedDatetimes($entity, array $datetimes)
68
-    {
69
-        $relationName = 'Datetime';
70
-        // Remove all the existing related datetimes
71
-
72
-        $entity->_remove_relations($relationName);
73
-        // @todo replace loop with single query
74
-        foreach ($datetimes as $ID) {
75
-            $parts = Relay::fromGlobalId($ID);
76
-            if (! empty($parts['id']) && absint($parts['id'])) {
77
-                $entity->_add_relation_to(
78
-                    $parts['id'],
79
-                    $relationName
80
-                );
81
-            }
82
-        }
83
-    }
84
-
85
-    /**
86
-     * Sets the related prices for the given ticket.
87
-     *
88
-     * @param EE_Ticket $entity The Ticket instance.
89
-     * @param array     $prices Array of entity IDs to relate.
90
-     */
91
-    public static function setRelatedPrices($entity, array $prices)
92
-    {
93
-        $relationName = 'Price';
94
-        // Remove all the existing related entities
95
-        $entity->_remove_relations($relationName);
96
-
97
-        // @todo replace loop with single query
98
-        foreach ($prices as $ID) {
99
-            $parts = Relay::fromGlobalId($ID);
100
-            if (! empty($parts['id']) && absint($parts['id'])) {
101
-                $entity->_add_relation_to(
102
-                    $parts['id'],
103
-                    $relationName
104
-                );
105
-            }
106
-        }
107
-    }
17
+	/**
18
+	 * Maps the GraphQL input to a format that the model functions can use
19
+	 *
20
+	 * @param array $input Data coming from the GraphQL mutation query input
21
+	 * @return array
22
+	 */
23
+	public static function prepareFields(array $input)
24
+	{
25
+
26
+		$args = [];
27
+
28
+		if (! empty($input['name'])) {
29
+			$args['TKT_name'] = sanitize_text_field($input['name']);
30
+		}
31
+
32
+		if (! empty($input['description'])) {
33
+			$args['TKT_description'] = sanitize_text_field($input['description']);
34
+		}
35
+
36
+		if (! empty($input['price'])) {
37
+			$args['TKT_price'] = floatval($input['price']);
38
+		}
39
+
40
+		if (! empty($input['startDate'])) {
41
+			$args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
42
+		}
43
+
44
+		if (! empty($input['endDate'])) {
45
+			$args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
46
+		}
47
+
48
+		if (! empty($input['datetimes'])) {
49
+			$args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
50
+		}
51
+
52
+		if (! empty($input['prices'])) {
53
+			$args['prices'] = array_map('sanitize_text_field', (array) $input['prices']);
54
+		}
55
+
56
+		// Likewise the other fields...
57
+
58
+		return $args;
59
+	}
60
+
61
+	/**
62
+	 * Sets the related datetimes for the given ticket.
63
+	 *
64
+	 * @param EE_Ticket $entity    The Ticket instance.
65
+	 * @param array     $datetimes Array of datetime IDs to relate.
66
+	 */
67
+	public static function setRelatedDatetimes($entity, array $datetimes)
68
+	{
69
+		$relationName = 'Datetime';
70
+		// Remove all the existing related datetimes
71
+
72
+		$entity->_remove_relations($relationName);
73
+		// @todo replace loop with single query
74
+		foreach ($datetimes as $ID) {
75
+			$parts = Relay::fromGlobalId($ID);
76
+			if (! empty($parts['id']) && absint($parts['id'])) {
77
+				$entity->_add_relation_to(
78
+					$parts['id'],
79
+					$relationName
80
+				);
81
+			}
82
+		}
83
+	}
84
+
85
+	/**
86
+	 * Sets the related prices for the given ticket.
87
+	 *
88
+	 * @param EE_Ticket $entity The Ticket instance.
89
+	 * @param array     $prices Array of entity IDs to relate.
90
+	 */
91
+	public static function setRelatedPrices($entity, array $prices)
92
+	{
93
+		$relationName = 'Price';
94
+		// Remove all the existing related entities
95
+		$entity->_remove_relations($relationName);
96
+
97
+		// @todo replace loop with single query
98
+		foreach ($prices as $ID) {
99
+			$parts = Relay::fromGlobalId($ID);
100
+			if (! empty($parts['id']) && absint($parts['id'])) {
101
+				$entity->_add_relation_to(
102
+					$parts['id'],
103
+					$relationName
104
+				);
105
+			}
106
+		}
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,31 +25,31 @@  discard block
 block discarded – undo
25 25
 
26 26
         $args = [];
27 27
 
28
-        if (! empty($input['name'])) {
28
+        if ( ! empty($input['name'])) {
29 29
             $args['TKT_name'] = sanitize_text_field($input['name']);
30 30
         }
31 31
 
32
-        if (! empty($input['description'])) {
32
+        if ( ! empty($input['description'])) {
33 33
             $args['TKT_description'] = sanitize_text_field($input['description']);
34 34
         }
35 35
 
36
-        if (! empty($input['price'])) {
36
+        if ( ! empty($input['price'])) {
37 37
             $args['TKT_price'] = floatval($input['price']);
38 38
         }
39 39
 
40
-        if (! empty($input['startDate'])) {
40
+        if ( ! empty($input['startDate'])) {
41 41
             $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
42 42
         }
43 43
 
44
-        if (! empty($input['endDate'])) {
44
+        if ( ! empty($input['endDate'])) {
45 45
             $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
46 46
         }
47 47
 
48
-        if (! empty($input['datetimes'])) {
48
+        if ( ! empty($input['datetimes'])) {
49 49
             $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
50 50
         }
51 51
 
52
-        if (! empty($input['prices'])) {
52
+        if ( ! empty($input['prices'])) {
53 53
             $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']);
54 54
         }
55 55
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         // @todo replace loop with single query
74 74
         foreach ($datetimes as $ID) {
75 75
             $parts = Relay::fromGlobalId($ID);
76
-            if (! empty($parts['id']) && absint($parts['id'])) {
76
+            if ( ! empty($parts['id']) && absint($parts['id'])) {
77 77
                 $entity->_add_relation_to(
78 78
                     $parts['id'],
79 79
                     $relationName
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         // @todo replace loop with single query
98 98
         foreach ($prices as $ID) {
99 99
             $parts = Relay::fromGlobalId($ID);
100
-            if (! empty($parts['id']) && absint($parts['id'])) {
100
+            if ( ! empty($parts['id']) && absint($parts['id'])) {
101 101
                 $entity->_add_relation_to(
102 102
                     $parts['id'],
103 103
                     $relationName
Please login to merge, or discard this patch.