Completed
Branch EDTR/master (77ece2)
by
unknown
40:25 queued 32:12
created
core/domain/services/graphql/types/Price.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 
53 53
     /**
54
-     * @return GraphQLFieldInterface[]
54
+     * @return GraphQLField[]
55 55
      * @since $VID:$
56 56
      */
57 57
     public function getFields()
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param array       $args    The inputArgs on the field
191 191
      * @param AppContext  $context The AppContext passed down the GraphQL tree
192 192
      * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
193
-     * @return string
193
+     * @return boolean
194 194
      * @throws EE_Error
195 195
      * @throws Exception
196 196
      * @throws InvalidArgumentException
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,6 @@
 block discarded – undo
13 13
 use EventEspresso\core\domain\services\graphql\mutators\PriceCreate;
14 14
 use EventEspresso\core\domain\services\graphql\mutators\PriceDelete;
15 15
 use EventEspresso\core\domain\services\graphql\mutators\PriceUpdate;
16
-
17 16
 use EE_Error;
18 17
 use Exception;
19 18
 use InvalidArgumentException;
Please login to merge, or discard this patch.
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -35,265 +35,265 @@
 block discarded – undo
35 35
 class Price extends TypeBase
36 36
 {
37 37
 
38
-    /**
39
-     * Price constructor.
40
-     *
41
-     * @param EEM_Price $price_model
42
-     */
43
-    public function __construct(EEM_Price $price_model)
44
-    {
45
-        $this->model = $price_model;
46
-        $this->setName('Price');
47
-        $this->setDescription(__('A price.', 'event_espresso'));
48
-        $this->setIsCustomPostType(false);
49
-        parent::__construct();
50
-    }
38
+	/**
39
+	 * Price constructor.
40
+	 *
41
+	 * @param EEM_Price $price_model
42
+	 */
43
+	public function __construct(EEM_Price $price_model)
44
+	{
45
+		$this->model = $price_model;
46
+		$this->setName('Price');
47
+		$this->setDescription(__('A price.', 'event_espresso'));
48
+		$this->setIsCustomPostType(false);
49
+		parent::__construct();
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * @return GraphQLFieldInterface[]
55
-     * @since $VID:$
56
-     */
57
-    public function getFields()
58
-    {
59
-        return [
60
-            new GraphQLField(
61
-                'id',
62
-                ['non_null' => 'ID'],
63
-                null,
64
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
65
-            ),
66
-            new GraphQLOutputField(
67
-                'dbId',
68
-                ['non_null' => 'Int'],
69
-                'ID',
70
-                esc_html__('Price ID', 'event_espresso')
71
-            ),
72
-            new GraphQLField(
73
-                'name',
74
-                'String',
75
-                'name',
76
-                esc_html__('Price Name', 'event_espresso')
77
-            ),
78
-            new GraphQLField(
79
-                'amount',
80
-                'Float',
81
-                'amount',
82
-                esc_html__('Price Amount', 'event_espresso')
83
-            ),
84
-            new GraphQLField(
85
-                'desc',
86
-                'String',
87
-                'desc',
88
-                esc_html__('Price description', 'event_espresso')
89
-            ),
90
-            new GraphQLField(
91
-                'overrides',
92
-                'Int',
93
-                'overrides',
94
-                esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso')
95
-            ),
96
-            new GraphQLField(
97
-                'order',
98
-                'Int',
99
-                'order',
100
-                esc_html__('Order of Application of Price.', 'event_espresso')
101
-            ),
102
-            new GraphQLOutputField(
103
-                'parent',
104
-                $this->name(),
105
-                null,
106
-                esc_html__('The parent price of the current price', 'event_espresso')
107
-            ),
108
-            new GraphQLInputField(
109
-                'parent',
110
-                'ID',
111
-                null,
112
-                esc_html__('The parent price ID', 'event_espresso')
113
-            ),
114
-            new GraphQLOutputField(
115
-                'priceType',
116
-                'PriceType',
117
-                'type_obj',
118
-                esc_html__('The related price type object.', 'event_espresso')
119
-            ),
120
-            new GraphQLOutputField(
121
-                'priceTypeOrder',
122
-                'Int',
123
-                null,
124
-                esc_html__('Order of Application of Price type.', 'event_espresso'),
125
-                null,
126
-                [$this, 'priceTypeOrder']
127
-            ),
128
-            new GraphQLInputField(
129
-                'priceType',
130
-                'ID',
131
-                null,
132
-                esc_html__('The price type ID', 'event_espresso')
133
-            ),
134
-            new GraphQLOutputField(
135
-                'isDeleted',
136
-                'Boolean',
137
-                'deleted',
138
-                esc_html__('Flag indicating price has been trashed.', 'event_espresso')
139
-            ),
140
-            new GraphQLField(
141
-                'isDefault',
142
-                'Boolean',
143
-                'is_default',
144
-                esc_html__('Flag indicating price is the default one.', 'event_espresso')
145
-            ),
146
-            new GraphQLOutputField(
147
-                'isPercent',
148
-                'Boolean',
149
-                'is_percent',
150
-                esc_html__('Flag indicating price is a percentage.', 'event_espresso')
151
-            ),
152
-            new GraphQLOutputField(
153
-                'isBasePrice',
154
-                'Boolean',
155
-                'is_base_price',
156
-                esc_html__('Flag indicating price is a base price type.', 'event_espresso')
157
-            ),
158
-            new GraphQLOutputField(
159
-                'isDiscount',
160
-                'Boolean',
161
-                'is_discount',
162
-                esc_html__('Flag indicating price is a discount.', 'event_espresso')
163
-            ),
164
-            new GraphQLOutputField(
165
-                'isTax',
166
-                'Boolean',
167
-                null,
168
-                esc_html__('Flag indicating price is a tax.', 'event_espresso'),
169
-                null,
170
-                [$this, 'isTax']
171
-            ),
172
-            new GraphQLOutputField(
173
-                'wpUser',
174
-                'User',
175
-                null,
176
-                esc_html__('Price Creator', 'event_espresso')
177
-            ),
178
-            new GraphQLInputField(
179
-                'wpUser',
180
-                'Int',
181
-                null,
182
-                esc_html__('Price Creator ID', 'event_espresso')
183
-            ),
184
-        ];
185
-    }
53
+	/**
54
+	 * @return GraphQLFieldInterface[]
55
+	 * @since $VID:$
56
+	 */
57
+	public function getFields()
58
+	{
59
+		return [
60
+			new GraphQLField(
61
+				'id',
62
+				['non_null' => 'ID'],
63
+				null,
64
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
65
+			),
66
+			new GraphQLOutputField(
67
+				'dbId',
68
+				['non_null' => 'Int'],
69
+				'ID',
70
+				esc_html__('Price ID', 'event_espresso')
71
+			),
72
+			new GraphQLField(
73
+				'name',
74
+				'String',
75
+				'name',
76
+				esc_html__('Price Name', 'event_espresso')
77
+			),
78
+			new GraphQLField(
79
+				'amount',
80
+				'Float',
81
+				'amount',
82
+				esc_html__('Price Amount', 'event_espresso')
83
+			),
84
+			new GraphQLField(
85
+				'desc',
86
+				'String',
87
+				'desc',
88
+				esc_html__('Price description', 'event_espresso')
89
+			),
90
+			new GraphQLField(
91
+				'overrides',
92
+				'Int',
93
+				'overrides',
94
+				esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso')
95
+			),
96
+			new GraphQLField(
97
+				'order',
98
+				'Int',
99
+				'order',
100
+				esc_html__('Order of Application of Price.', 'event_espresso')
101
+			),
102
+			new GraphQLOutputField(
103
+				'parent',
104
+				$this->name(),
105
+				null,
106
+				esc_html__('The parent price of the current price', 'event_espresso')
107
+			),
108
+			new GraphQLInputField(
109
+				'parent',
110
+				'ID',
111
+				null,
112
+				esc_html__('The parent price ID', 'event_espresso')
113
+			),
114
+			new GraphQLOutputField(
115
+				'priceType',
116
+				'PriceType',
117
+				'type_obj',
118
+				esc_html__('The related price type object.', 'event_espresso')
119
+			),
120
+			new GraphQLOutputField(
121
+				'priceTypeOrder',
122
+				'Int',
123
+				null,
124
+				esc_html__('Order of Application of Price type.', 'event_espresso'),
125
+				null,
126
+				[$this, 'priceTypeOrder']
127
+			),
128
+			new GraphQLInputField(
129
+				'priceType',
130
+				'ID',
131
+				null,
132
+				esc_html__('The price type ID', 'event_espresso')
133
+			),
134
+			new GraphQLOutputField(
135
+				'isDeleted',
136
+				'Boolean',
137
+				'deleted',
138
+				esc_html__('Flag indicating price has been trashed.', 'event_espresso')
139
+			),
140
+			new GraphQLField(
141
+				'isDefault',
142
+				'Boolean',
143
+				'is_default',
144
+				esc_html__('Flag indicating price is the default one.', 'event_espresso')
145
+			),
146
+			new GraphQLOutputField(
147
+				'isPercent',
148
+				'Boolean',
149
+				'is_percent',
150
+				esc_html__('Flag indicating price is a percentage.', 'event_espresso')
151
+			),
152
+			new GraphQLOutputField(
153
+				'isBasePrice',
154
+				'Boolean',
155
+				'is_base_price',
156
+				esc_html__('Flag indicating price is a base price type.', 'event_espresso')
157
+			),
158
+			new GraphQLOutputField(
159
+				'isDiscount',
160
+				'Boolean',
161
+				'is_discount',
162
+				esc_html__('Flag indicating price is a discount.', 'event_espresso')
163
+			),
164
+			new GraphQLOutputField(
165
+				'isTax',
166
+				'Boolean',
167
+				null,
168
+				esc_html__('Flag indicating price is a tax.', 'event_espresso'),
169
+				null,
170
+				[$this, 'isTax']
171
+			),
172
+			new GraphQLOutputField(
173
+				'wpUser',
174
+				'User',
175
+				null,
176
+				esc_html__('Price Creator', 'event_espresso')
177
+			),
178
+			new GraphQLInputField(
179
+				'wpUser',
180
+				'Int',
181
+				null,
182
+				esc_html__('Price Creator ID', 'event_espresso')
183
+			),
184
+		];
185
+	}
186 186
 
187 187
 
188
-    /**
189
-     * @param EE_Price    $source  The source that's passed down the GraphQL queries
190
-     * @param array       $args    The inputArgs on the field
191
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
192
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
193
-     * @return string
194
-     * @throws EE_Error
195
-     * @throws Exception
196
-     * @throws InvalidArgumentException
197
-     * @throws InvalidDataTypeException
198
-     * @throws InvalidInterfaceException
199
-     * @throws ReflectionException
200
-     * @throws UserError
201
-     * @throws UnexpectedEntityException
202
-     * @since $VID:$
203
-     */
204
-    public function isTax(EE_Price $source, array $args, AppContext $context, ResolveInfo $info)
205
-    {
206
-        $price_type = $source->type_obj();
207
-        return $price_type->base_type() === EEM_Price_Type::base_type_tax;
208
-    }
188
+	/**
189
+	 * @param EE_Price    $source  The source that's passed down the GraphQL queries
190
+	 * @param array       $args    The inputArgs on the field
191
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
192
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
193
+	 * @return string
194
+	 * @throws EE_Error
195
+	 * @throws Exception
196
+	 * @throws InvalidArgumentException
197
+	 * @throws InvalidDataTypeException
198
+	 * @throws InvalidInterfaceException
199
+	 * @throws ReflectionException
200
+	 * @throws UserError
201
+	 * @throws UnexpectedEntityException
202
+	 * @since $VID:$
203
+	 */
204
+	public function isTax(EE_Price $source, array $args, AppContext $context, ResolveInfo $info)
205
+	{
206
+		$price_type = $source->type_obj();
207
+		return $price_type->base_type() === EEM_Price_Type::base_type_tax;
208
+	}
209 209
 
210 210
 
211
-    /**
212
-     * @param EE_Price    $source  The source that's passed down the GraphQL queries
213
-     * @param array       $args    The inputArgs on the field
214
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
215
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
216
-     * @return string
217
-     * @throws EE_Error
218
-     * @throws Exception
219
-     * @throws InvalidArgumentException
220
-     * @throws InvalidDataTypeException
221
-     * @throws InvalidInterfaceException
222
-     * @throws ReflectionException
223
-     * @throws UserError
224
-     * @throws UnexpectedEntityException
225
-     * @since $VID:$
226
-     */
227
-    public function priceTypeOrder(EE_Price $source, array $args, AppContext $context, ResolveInfo $info)
228
-    {
229
-        $price_type = $source->type_obj();
230
-        return $price_type->order();
231
-    }
211
+	/**
212
+	 * @param EE_Price    $source  The source that's passed down the GraphQL queries
213
+	 * @param array       $args    The inputArgs on the field
214
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
215
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
216
+	 * @return string
217
+	 * @throws EE_Error
218
+	 * @throws Exception
219
+	 * @throws InvalidArgumentException
220
+	 * @throws InvalidDataTypeException
221
+	 * @throws InvalidInterfaceException
222
+	 * @throws ReflectionException
223
+	 * @throws UserError
224
+	 * @throws UnexpectedEntityException
225
+	 * @since $VID:$
226
+	 */
227
+	public function priceTypeOrder(EE_Price $source, array $args, AppContext $context, ResolveInfo $info)
228
+	{
229
+		$price_type = $source->type_obj();
230
+		return $price_type->order();
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * @param array $inputFields The mutation input fields.
236
-     * @throws InvalidArgumentException
237
-     * @throws ReflectionException
238
-     * @since $VID:$
239
-     */
240
-    public function registerMutations(array $inputFields)
241
-    {
242
-        // Register mutation to update an entity.
243
-        register_graphql_mutation(
244
-            'update' . $this->name(),
245
-            [
246
-                'inputFields'         => $inputFields,
247
-                'outputFields'        => [
248
-                    lcfirst($this->name()) => [
249
-                        'type'    => $this->name(),
250
-                        'resolve' => [$this, 'resolveFromPayload'],
251
-                    ],
252
-                ],
253
-                'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this),
254
-            ]
255
-        );
256
-        // Register mutation to delete an entity.
257
-        register_graphql_mutation(
258
-            'delete' . $this->name(),
259
-            [
260
-                'inputFields'         => [
261
-                    'id'                => $inputFields['id'],
262
-                    'deletePermanently' => [
263
-                        'type'        => 'Boolean',
264
-                        'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
265
-                    ],
266
-                ],
267
-                'outputFields'        => [
268
-                    lcfirst($this->name()) => [
269
-                        'type'        => $this->name(),
270
-                        'description' => esc_html__('The object before it was deleted', 'event_espresso'),
271
-                        'resolve'     => static function ($payload) {
272
-                            $deleted = (object) $payload['deleted'];
234
+	/**
235
+	 * @param array $inputFields The mutation input fields.
236
+	 * @throws InvalidArgumentException
237
+	 * @throws ReflectionException
238
+	 * @since $VID:$
239
+	 */
240
+	public function registerMutations(array $inputFields)
241
+	{
242
+		// Register mutation to update an entity.
243
+		register_graphql_mutation(
244
+			'update' . $this->name(),
245
+			[
246
+				'inputFields'         => $inputFields,
247
+				'outputFields'        => [
248
+					lcfirst($this->name()) => [
249
+						'type'    => $this->name(),
250
+						'resolve' => [$this, 'resolveFromPayload'],
251
+					],
252
+				],
253
+				'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this),
254
+			]
255
+		);
256
+		// Register mutation to delete an entity.
257
+		register_graphql_mutation(
258
+			'delete' . $this->name(),
259
+			[
260
+				'inputFields'         => [
261
+					'id'                => $inputFields['id'],
262
+					'deletePermanently' => [
263
+						'type'        => 'Boolean',
264
+						'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
265
+					],
266
+				],
267
+				'outputFields'        => [
268
+					lcfirst($this->name()) => [
269
+						'type'        => $this->name(),
270
+						'description' => esc_html__('The object before it was deleted', 'event_espresso'),
271
+						'resolve'     => static function ($payload) {
272
+							$deleted = (object) $payload['deleted'];
273 273
 
274
-                            return ! empty($deleted) ? $deleted : null;
275
-                        },
276
-                    ],
277
-                ],
278
-                'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this),
279
-            ]
280
-        );
274
+							return ! empty($deleted) ? $deleted : null;
275
+						},
276
+					],
277
+				],
278
+				'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this),
279
+			]
280
+		);
281 281
 
282
-        // remove primary key from input.
283
-        unset($inputFields['id']);
284
-        // Register mutation to update an entity.
285
-        register_graphql_mutation(
286
-            'create' . $this->name(),
287
-            [
288
-                'inputFields'         => $inputFields,
289
-                'outputFields'        => [
290
-                    lcfirst($this->name()) => [
291
-                        'type'    => $this->name(),
292
-                        'resolve' => [$this, 'resolveFromPayload'],
293
-                    ],
294
-                ],
295
-                'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this),
296
-            ]
297
-        );
298
-    }
282
+		// remove primary key from input.
283
+		unset($inputFields['id']);
284
+		// Register mutation to update an entity.
285
+		register_graphql_mutation(
286
+			'create' . $this->name(),
287
+			[
288
+				'inputFields'         => $inputFields,
289
+				'outputFields'        => [
290
+					lcfirst($this->name()) => [
291
+						'type'    => $this->name(),
292
+						'resolve' => [$this, 'resolveFromPayload'],
293
+					],
294
+				],
295
+				'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this),
296
+			]
297
+		);
298
+	}
299 299
 }
Please login to merge, or discard this patch.