@@ -14,7 +14,7 @@ |
||
14 | 14 | * |
15 | 15 | * @param EEM_Datetime $model |
16 | 16 | * @param Datetime $type |
17 | - * @return callable |
|
17 | + * @return \Closure |
|
18 | 18 | */ |
19 | 19 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
20 | 20 | { |
@@ -12,8 +12,8 @@ |
||
12 | 12 | /** |
13 | 13 | * Defines the mutation data modification closure. |
14 | 14 | * |
15 | - * @param EEM_Datetime $model |
|
16 | - * @param Datetime $type |
|
15 | + * @param EEM_Datetime $model |
|
16 | + * @param Datetime $type |
|
17 | 17 | * @return callable |
18 | 18 | */ |
19 | 19 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
23 | 23 | { |
24 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
24 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
25 | 25 | { |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Stop now if a user isn't allowed to create a datetime. |
29 | 29 | */ |
30 | - if (! current_user_can('ee_edit_events')) { |
|
30 | + if ( ! current_user_can('ee_edit_events')) { |
|
31 | 31 | // translators: the %1$s is the name of the object being mutated |
32 | - throw new UserError(sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso' ), $type->name())); |
|
32 | + throw new UserError(sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name())); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $args = DatetimeMutation::prepare_fields($input, $mutation_name); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $id = $entity->save(); |
39 | 39 | |
40 | 40 | if (empty($id)) { |
41 | - throw new UserError(__( 'The object failed to create but no error was provided', 'event_espresso')); |
|
41 | + throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return [ |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
43 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
43 | + * @return GraphQLField[] |
|
44 | 44 | * @since $VID:$ |
45 | 45 | */ |
46 | 46 | public function getFields() |
@@ -24,210 +24,210 @@ |
||
24 | 24 | class Datetime extends TypeBase |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * EventDate constructor. |
|
29 | - * |
|
30 | - * @param EEM_Datetime $datetime_model |
|
31 | - */ |
|
32 | - public function __construct(EEM_Datetime $datetime_model) |
|
33 | - { |
|
34 | - $this->model = $datetime_model; |
|
35 | - $this->setName('Datetime'); |
|
36 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
37 | - $this->setIsCustomPostType(false); |
|
38 | - parent::__construct(); |
|
39 | - } |
|
27 | + /** |
|
28 | + * EventDate constructor. |
|
29 | + * |
|
30 | + * @param EEM_Datetime $datetime_model |
|
31 | + */ |
|
32 | + public function __construct(EEM_Datetime $datetime_model) |
|
33 | + { |
|
34 | + $this->model = $datetime_model; |
|
35 | + $this->setName('Datetime'); |
|
36 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
37 | + $this->setIsCustomPostType(false); |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
44 | - * @since $VID:$ |
|
45 | - */ |
|
46 | - public function getFields() |
|
47 | - { |
|
48 | - return [ |
|
49 | - new GraphQLField( |
|
50 | - 'id', |
|
51 | - ['non_null' => 'Int'], |
|
52 | - 'ID', |
|
53 | - __('The datetime ID.', 'event_espresso') |
|
54 | - ), |
|
55 | - new GraphQLField( |
|
56 | - 'name', |
|
57 | - 'String', |
|
58 | - 'name', |
|
59 | - __('Datetime Name', 'event_espresso') |
|
60 | - ), |
|
61 | - new GraphQLField( |
|
62 | - 'description', |
|
63 | - 'String', |
|
64 | - 'description', |
|
65 | - __('Description for Datetime', 'event_espresso') |
|
66 | - ), |
|
67 | - new GraphQLField( |
|
68 | - 'start', |
|
69 | - 'String', |
|
70 | - 'start', |
|
71 | - __('Start timestamp of Event', 'event_espresso') |
|
72 | - ), |
|
73 | - new GraphQLField( |
|
74 | - 'startDate', |
|
75 | - 'String', |
|
76 | - 'start_date', |
|
77 | - __('Start time/date of Event', 'event_espresso') |
|
78 | - ), |
|
79 | - new GraphQLField( |
|
80 | - 'end', |
|
81 | - 'String', |
|
82 | - 'end', |
|
83 | - __('End timestamp of Event', 'event_espresso') |
|
84 | - ), |
|
85 | - new GraphQLField( |
|
86 | - 'endDate', |
|
87 | - 'String', |
|
88 | - 'end_date', |
|
89 | - __('End time/date of Event', 'event_espresso') |
|
90 | - ), |
|
91 | - new GraphQLField( |
|
92 | - 'startTime', |
|
93 | - 'String', |
|
94 | - 'start_time', |
|
95 | - __('Start time of Event', 'event_espresso') |
|
96 | - ), |
|
97 | - new GraphQLField( |
|
98 | - 'endTime', |
|
99 | - 'String', |
|
100 | - 'end_time', |
|
101 | - __('End time of Event', 'event_espresso') |
|
102 | - ), |
|
103 | - new GraphQLField( |
|
104 | - 'capacity', |
|
105 | - 'Int', |
|
106 | - 'reg_limit', |
|
107 | - __('Registration Limit for this time', 'event_espresso'), |
|
108 | - [$this, 'parseInfiniteValue'] |
|
109 | - ), |
|
110 | - new GraphQLField( |
|
111 | - 'sold', |
|
112 | - 'Int', |
|
113 | - 'sold', |
|
114 | - __('How many sales for this Datetime that have occurred', 'event_espresso') |
|
115 | - ), |
|
116 | - new GraphQLField( |
|
117 | - 'reserved', |
|
118 | - 'Int', |
|
119 | - 'reserved', |
|
120 | - __('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
121 | - ), |
|
122 | - new GraphQLField( |
|
123 | - 'order', |
|
124 | - 'Int', |
|
125 | - 'order', |
|
126 | - __('The order in which the Datetime is displayed', 'event_espresso') |
|
127 | - ), |
|
128 | - new GraphQLField( |
|
129 | - 'length', |
|
130 | - 'Int', |
|
131 | - 'length', |
|
132 | - __('The length of the event (start to end time) in seconds', 'event_espresso') |
|
133 | - ), |
|
134 | - new GraphQLOutputField( |
|
135 | - 'parent', |
|
136 | - 'Datetime', |
|
137 | - null, |
|
138 | - __('The parent datetime of the current datetime', 'event_espresso') |
|
139 | - ), |
|
140 | - new GraphQLInputField( |
|
141 | - 'parent', |
|
142 | - 'Int', |
|
143 | - null, |
|
144 | - __('The parent datetime ID', 'event_espresso') |
|
145 | - ), |
|
146 | - new GraphQLField( |
|
147 | - 'isPrimary', |
|
148 | - 'Boolean', |
|
149 | - 'is_primary', |
|
150 | - __('Flag indicating datetime is primary one for event', 'event_espresso') |
|
151 | - ), |
|
152 | - new GraphQLField( |
|
153 | - 'isSoldOut', |
|
154 | - 'Boolean', |
|
155 | - 'sold_out', |
|
156 | - __('Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
157 | - 'event_espresso') |
|
158 | - ), |
|
159 | - new GraphQLField( |
|
160 | - 'isUpcoming', |
|
161 | - 'Boolean', |
|
162 | - 'is_upcoming', |
|
163 | - __('Whether the date is upcoming', 'event_espresso') |
|
164 | - ), |
|
165 | - new GraphQLField( |
|
166 | - 'isActive', |
|
167 | - 'Boolean', |
|
168 | - 'is_active', |
|
169 | - __('Flag indicating datetime is active', 'event_espresso') |
|
170 | - ), |
|
171 | - new GraphQLField( |
|
172 | - 'isExpired', |
|
173 | - 'Boolean', |
|
174 | - 'is_expired', |
|
175 | - __('Flag indicating datetime is expired or not', 'event_espresso') |
|
176 | - ), |
|
177 | - new GraphQLOutputField( |
|
178 | - 'event', |
|
179 | - 'Event', |
|
180 | - null, |
|
181 | - __('Event of the datetime.', 'event_espresso') |
|
182 | - ), |
|
183 | - new GraphQLInputField( |
|
184 | - 'event', |
|
185 | - 'Int', |
|
186 | - null, |
|
187 | - __('Event ID of the datetime.', 'event_espresso') |
|
188 | - ), |
|
189 | - ]; |
|
190 | - } |
|
42 | + /** |
|
43 | + * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
44 | + * @since $VID:$ |
|
45 | + */ |
|
46 | + public function getFields() |
|
47 | + { |
|
48 | + return [ |
|
49 | + new GraphQLField( |
|
50 | + 'id', |
|
51 | + ['non_null' => 'Int'], |
|
52 | + 'ID', |
|
53 | + __('The datetime ID.', 'event_espresso') |
|
54 | + ), |
|
55 | + new GraphQLField( |
|
56 | + 'name', |
|
57 | + 'String', |
|
58 | + 'name', |
|
59 | + __('Datetime Name', 'event_espresso') |
|
60 | + ), |
|
61 | + new GraphQLField( |
|
62 | + 'description', |
|
63 | + 'String', |
|
64 | + 'description', |
|
65 | + __('Description for Datetime', 'event_espresso') |
|
66 | + ), |
|
67 | + new GraphQLField( |
|
68 | + 'start', |
|
69 | + 'String', |
|
70 | + 'start', |
|
71 | + __('Start timestamp of Event', 'event_espresso') |
|
72 | + ), |
|
73 | + new GraphQLField( |
|
74 | + 'startDate', |
|
75 | + 'String', |
|
76 | + 'start_date', |
|
77 | + __('Start time/date of Event', 'event_espresso') |
|
78 | + ), |
|
79 | + new GraphQLField( |
|
80 | + 'end', |
|
81 | + 'String', |
|
82 | + 'end', |
|
83 | + __('End timestamp of Event', 'event_espresso') |
|
84 | + ), |
|
85 | + new GraphQLField( |
|
86 | + 'endDate', |
|
87 | + 'String', |
|
88 | + 'end_date', |
|
89 | + __('End time/date of Event', 'event_espresso') |
|
90 | + ), |
|
91 | + new GraphQLField( |
|
92 | + 'startTime', |
|
93 | + 'String', |
|
94 | + 'start_time', |
|
95 | + __('Start time of Event', 'event_espresso') |
|
96 | + ), |
|
97 | + new GraphQLField( |
|
98 | + 'endTime', |
|
99 | + 'String', |
|
100 | + 'end_time', |
|
101 | + __('End time of Event', 'event_espresso') |
|
102 | + ), |
|
103 | + new GraphQLField( |
|
104 | + 'capacity', |
|
105 | + 'Int', |
|
106 | + 'reg_limit', |
|
107 | + __('Registration Limit for this time', 'event_espresso'), |
|
108 | + [$this, 'parseInfiniteValue'] |
|
109 | + ), |
|
110 | + new GraphQLField( |
|
111 | + 'sold', |
|
112 | + 'Int', |
|
113 | + 'sold', |
|
114 | + __('How many sales for this Datetime that have occurred', 'event_espresso') |
|
115 | + ), |
|
116 | + new GraphQLField( |
|
117 | + 'reserved', |
|
118 | + 'Int', |
|
119 | + 'reserved', |
|
120 | + __('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
121 | + ), |
|
122 | + new GraphQLField( |
|
123 | + 'order', |
|
124 | + 'Int', |
|
125 | + 'order', |
|
126 | + __('The order in which the Datetime is displayed', 'event_espresso') |
|
127 | + ), |
|
128 | + new GraphQLField( |
|
129 | + 'length', |
|
130 | + 'Int', |
|
131 | + 'length', |
|
132 | + __('The length of the event (start to end time) in seconds', 'event_espresso') |
|
133 | + ), |
|
134 | + new GraphQLOutputField( |
|
135 | + 'parent', |
|
136 | + 'Datetime', |
|
137 | + null, |
|
138 | + __('The parent datetime of the current datetime', 'event_espresso') |
|
139 | + ), |
|
140 | + new GraphQLInputField( |
|
141 | + 'parent', |
|
142 | + 'Int', |
|
143 | + null, |
|
144 | + __('The parent datetime ID', 'event_espresso') |
|
145 | + ), |
|
146 | + new GraphQLField( |
|
147 | + 'isPrimary', |
|
148 | + 'Boolean', |
|
149 | + 'is_primary', |
|
150 | + __('Flag indicating datetime is primary one for event', 'event_espresso') |
|
151 | + ), |
|
152 | + new GraphQLField( |
|
153 | + 'isSoldOut', |
|
154 | + 'Boolean', |
|
155 | + 'sold_out', |
|
156 | + __('Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
157 | + 'event_espresso') |
|
158 | + ), |
|
159 | + new GraphQLField( |
|
160 | + 'isUpcoming', |
|
161 | + 'Boolean', |
|
162 | + 'is_upcoming', |
|
163 | + __('Whether the date is upcoming', 'event_espresso') |
|
164 | + ), |
|
165 | + new GraphQLField( |
|
166 | + 'isActive', |
|
167 | + 'Boolean', |
|
168 | + 'is_active', |
|
169 | + __('Flag indicating datetime is active', 'event_espresso') |
|
170 | + ), |
|
171 | + new GraphQLField( |
|
172 | + 'isExpired', |
|
173 | + 'Boolean', |
|
174 | + 'is_expired', |
|
175 | + __('Flag indicating datetime is expired or not', 'event_espresso') |
|
176 | + ), |
|
177 | + new GraphQLOutputField( |
|
178 | + 'event', |
|
179 | + 'Event', |
|
180 | + null, |
|
181 | + __('Event of the datetime.', 'event_espresso') |
|
182 | + ), |
|
183 | + new GraphQLInputField( |
|
184 | + 'event', |
|
185 | + 'Int', |
|
186 | + null, |
|
187 | + __('Event ID of the datetime.', 'event_espresso') |
|
188 | + ), |
|
189 | + ]; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | - /** |
|
194 | - * @param array $inputFields The mutation input fields. |
|
195 | - * |
|
196 | - * @throws InvalidArgumentException |
|
197 | - * @throws ReflectionException |
|
198 | - * @since $VID:$ |
|
199 | - */ |
|
200 | - public function registerMutations(array $inputFields) |
|
201 | - { |
|
202 | - // Register mutation to update an entity. |
|
203 | - register_graphql_mutation( |
|
193 | + /** |
|
194 | + * @param array $inputFields The mutation input fields. |
|
195 | + * |
|
196 | + * @throws InvalidArgumentException |
|
197 | + * @throws ReflectionException |
|
198 | + * @since $VID:$ |
|
199 | + */ |
|
200 | + public function registerMutations(array $inputFields) |
|
201 | + { |
|
202 | + // Register mutation to update an entity. |
|
203 | + register_graphql_mutation( |
|
204 | 204 | 'update' . $this->name(), |
205 | 205 | [ |
206 | 206 | 'inputFields' => $inputFields, |
207 | 207 | 'outputFields' => [ |
208 | - lcfirst($this->name()) => [ |
|
209 | - 'type' => $this->name(), |
|
210 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
211 | - ], |
|
212 | - ], |
|
208 | + lcfirst($this->name()) => [ |
|
209 | + 'type' => $this->name(), |
|
210 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
211 | + ], |
|
212 | + ], |
|
213 | 213 | 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
214 | 214 | ] |
215 | - ); |
|
216 | - // remove primary key from input. |
|
217 | - unset($inputFields['id']); |
|
218 | - // Register mutation to update an entity. |
|
219 | - register_graphql_mutation( |
|
215 | + ); |
|
216 | + // remove primary key from input. |
|
217 | + unset($inputFields['id']); |
|
218 | + // Register mutation to update an entity. |
|
219 | + register_graphql_mutation( |
|
220 | 220 | 'create' . $this->name(), |
221 | 221 | [ |
222 | 222 | 'inputFields' => $inputFields, |
223 | 223 | 'outputFields' => [ |
224 | - lcfirst($this->name()) => [ |
|
225 | - 'type' => $this->name(), |
|
226 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
227 | - ], |
|
228 | - ], |
|
224 | + lcfirst($this->name()) => [ |
|
225 | + 'type' => $this->name(), |
|
226 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
227 | + ], |
|
228 | + ], |
|
229 | 229 | 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
230 | 230 | ] |
231 | 231 | ); |
232 | - } |
|
232 | + } |
|
233 | 233 | } |
234 | 234 | \ No newline at end of file |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | // Register mutation to update an entity. |
203 | 203 | register_graphql_mutation( |
204 | - 'update' . $this->name(), |
|
204 | + 'update'.$this->name(), |
|
205 | 205 | [ |
206 | 206 | 'inputFields' => $inputFields, |
207 | 207 | 'outputFields' => [ |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | unset($inputFields['id']); |
218 | 218 | // Register mutation to update an entity. |
219 | 219 | register_graphql_mutation( |
220 | - 'create' . $this->name(), |
|
220 | + 'create'.$this->name(), |
|
221 | 221 | [ |
222 | 222 | 'inputFields' => $inputFields, |
223 | 223 | 'outputFields' => [ |
@@ -243,7 +243,7 @@ |
||
243 | 243 | * @param mixed $payload The payload returned after mutation |
244 | 244 | * @param array $args The inputArgs on the field |
245 | 245 | * @param AppContext $context The AppContext passed down the GraphQL tree |
246 | - * @return string |
|
246 | + * @return null|EE_Base_Class |
|
247 | 247 | * @throws EE_Error |
248 | 248 | * @throws InvalidDataTypeException |
249 | 249 | * @throws InvalidInterfaceException |
@@ -29,235 +29,235 @@ |
||
29 | 29 | abstract class TypeBase implements TypeInterface |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var EEM_Base $model |
|
34 | - */ |
|
35 | - protected $model; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string $name |
|
39 | - */ |
|
40 | - protected $name = ''; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string $description |
|
44 | - */ |
|
45 | - protected $description = ''; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] $fields |
|
49 | - */ |
|
50 | - protected $fields = []; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var array $graphql_to_model_map |
|
54 | - */ |
|
55 | - protected $graphql_to_model_map = []; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var FieldResolver $field_resolver |
|
59 | - */ |
|
60 | - protected $field_resolver; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var bool $is_custom_post_type |
|
64 | - */ |
|
65 | - protected $is_custom_post_type = false; |
|
66 | - |
|
67 | - /** |
|
68 | - * TypeBase constructor. |
|
69 | - */ |
|
70 | - public function __construct() |
|
71 | - { |
|
72 | - $this->setFields($this->getFields()); |
|
73 | - $this->field_resolver = new FieldResolver( |
|
74 | - $this->model, |
|
75 | - $this->getFieldsForResolver() |
|
76 | - ); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
82 | - * @since $VID:$ |
|
83 | - */ |
|
84 | - abstract protected function getFields(); |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function name() |
|
91 | - { |
|
92 | - return $this->name; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $name |
|
98 | - */ |
|
99 | - protected function setName($name) |
|
100 | - { |
|
101 | - $this->name = $name; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function description() |
|
109 | - { |
|
110 | - return $this->description; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @param string $description |
|
116 | - */ |
|
117 | - protected function setDescription($description) |
|
118 | - { |
|
119 | - $this->description = $description; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
125 | - * @since $VID:$ |
|
126 | - */ |
|
127 | - public function fields() |
|
128 | - { |
|
129 | - return (array) $this->fields; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @param \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] $fields |
|
135 | - */ |
|
136 | - protected function setFields(array $fields) |
|
137 | - { |
|
138 | - foreach ($fields as $field) { |
|
139 | - if ($field instanceof GraphQLField) { |
|
140 | - $this->fields[] = $field; |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Creates a key map for internal resolver. |
|
148 | - * @return array |
|
149 | - * @since $VID:$ |
|
150 | - */ |
|
151 | - public function getFieldsForResolver() |
|
152 | - { |
|
153 | - $fields = []; |
|
154 | - foreach ($this->fields() as $field) { |
|
155 | - if ($field->useForOutput()) { |
|
156 | - $fields[$field->name()] = $field; |
|
157 | - } |
|
158 | - } |
|
159 | - return $fields; |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @return bool |
|
165 | - */ |
|
166 | - public function isCustomPostType() |
|
167 | - { |
|
168 | - return $this->is_custom_post_type; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * @param bool $is_custom_post_type |
|
174 | - */ |
|
175 | - protected function setIsCustomPostType($is_custom_post_type) |
|
176 | - { |
|
177 | - $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * @param int $value |
|
183 | - * @return int |
|
184 | - * @since $VID:$ |
|
185 | - */ |
|
186 | - public function parseInfiniteValue($value) |
|
187 | - { |
|
188 | - $value = trim($value); |
|
189 | - return $value === null |
|
190 | - || $value === '' |
|
191 | - || $value === '∞' |
|
192 | - || $value === 'INF' |
|
193 | - || $value === INF |
|
194 | - || $value === EE_INF |
|
195 | - || is_infinite((float) $value) |
|
196 | - ? -1 |
|
197 | - : $value; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * @param mixed $source |
|
203 | - * @return EE_Base_Class|null |
|
204 | - * @since $VID:$ |
|
205 | - */ |
|
206 | - private function getModel($source) |
|
207 | - { |
|
208 | - // If it comes from a custom connection |
|
209 | - // where the $source is already instantiated. |
|
210 | - if ($source instanceof EE_Base_Class) { |
|
211 | - return $source; |
|
212 | - } |
|
213 | - return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
219 | - * @param array $args The inputArgs on the field |
|
220 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
221 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
222 | - * @return string |
|
223 | - * @throws EE_Error |
|
224 | - * @throws InvalidDataTypeException |
|
225 | - * @throws InvalidInterfaceException |
|
226 | - * @throws UnexpectedEntityException |
|
227 | - * @throws UserError |
|
228 | - * @throws InvalidArgumentException |
|
229 | - * @throws ReflectionException |
|
230 | - * @since $VID:$ |
|
231 | - */ |
|
232 | - public function resolveField($source, $args, AppContext $context, ResolveInfo $info) |
|
233 | - { |
|
234 | - $source = $this->getModel($source); |
|
235 | - if ($source instanceof EE_Base_Class) { |
|
236 | - return $this->field_resolver->resolve($source, $args, $context, $info); |
|
237 | - } |
|
238 | - return null; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * @param mixed $payload The payload returned after mutation |
|
244 | - * @param array $args The inputArgs on the field |
|
245 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
246 | - * @return string |
|
247 | - * @throws EE_Error |
|
248 | - * @throws InvalidDataTypeException |
|
249 | - * @throws InvalidInterfaceException |
|
250 | - * @throws UnexpectedEntityException |
|
251 | - * @throws UserError |
|
252 | - * @throws InvalidArgumentException |
|
253 | - * @throws ReflectionException |
|
254 | - * @since $VID:$ |
|
255 | - */ |
|
256 | - public function resolveFromPayload($payload, $args, AppContext $context) |
|
257 | - { |
|
258 | - if ( empty( $payload['id'] ) || ! absint( $payload['id'] ) ) { |
|
259 | - return null; |
|
260 | - } |
|
261 | - return $this->model->get_one_by_ID($payload['id']); |
|
262 | - } |
|
32 | + /** |
|
33 | + * @var EEM_Base $model |
|
34 | + */ |
|
35 | + protected $model; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string $name |
|
39 | + */ |
|
40 | + protected $name = ''; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string $description |
|
44 | + */ |
|
45 | + protected $description = ''; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] $fields |
|
49 | + */ |
|
50 | + protected $fields = []; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var array $graphql_to_model_map |
|
54 | + */ |
|
55 | + protected $graphql_to_model_map = []; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var FieldResolver $field_resolver |
|
59 | + */ |
|
60 | + protected $field_resolver; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var bool $is_custom_post_type |
|
64 | + */ |
|
65 | + protected $is_custom_post_type = false; |
|
66 | + |
|
67 | + /** |
|
68 | + * TypeBase constructor. |
|
69 | + */ |
|
70 | + public function __construct() |
|
71 | + { |
|
72 | + $this->setFields($this->getFields()); |
|
73 | + $this->field_resolver = new FieldResolver( |
|
74 | + $this->model, |
|
75 | + $this->getFieldsForResolver() |
|
76 | + ); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
82 | + * @since $VID:$ |
|
83 | + */ |
|
84 | + abstract protected function getFields(); |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function name() |
|
91 | + { |
|
92 | + return $this->name; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $name |
|
98 | + */ |
|
99 | + protected function setName($name) |
|
100 | + { |
|
101 | + $this->name = $name; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function description() |
|
109 | + { |
|
110 | + return $this->description; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @param string $description |
|
116 | + */ |
|
117 | + protected function setDescription($description) |
|
118 | + { |
|
119 | + $this->description = $description; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
125 | + * @since $VID:$ |
|
126 | + */ |
|
127 | + public function fields() |
|
128 | + { |
|
129 | + return (array) $this->fields; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @param \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] $fields |
|
135 | + */ |
|
136 | + protected function setFields(array $fields) |
|
137 | + { |
|
138 | + foreach ($fields as $field) { |
|
139 | + if ($field instanceof GraphQLField) { |
|
140 | + $this->fields[] = $field; |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Creates a key map for internal resolver. |
|
148 | + * @return array |
|
149 | + * @since $VID:$ |
|
150 | + */ |
|
151 | + public function getFieldsForResolver() |
|
152 | + { |
|
153 | + $fields = []; |
|
154 | + foreach ($this->fields() as $field) { |
|
155 | + if ($field->useForOutput()) { |
|
156 | + $fields[$field->name()] = $field; |
|
157 | + } |
|
158 | + } |
|
159 | + return $fields; |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @return bool |
|
165 | + */ |
|
166 | + public function isCustomPostType() |
|
167 | + { |
|
168 | + return $this->is_custom_post_type; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * @param bool $is_custom_post_type |
|
174 | + */ |
|
175 | + protected function setIsCustomPostType($is_custom_post_type) |
|
176 | + { |
|
177 | + $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * @param int $value |
|
183 | + * @return int |
|
184 | + * @since $VID:$ |
|
185 | + */ |
|
186 | + public function parseInfiniteValue($value) |
|
187 | + { |
|
188 | + $value = trim($value); |
|
189 | + return $value === null |
|
190 | + || $value === '' |
|
191 | + || $value === '∞' |
|
192 | + || $value === 'INF' |
|
193 | + || $value === INF |
|
194 | + || $value === EE_INF |
|
195 | + || is_infinite((float) $value) |
|
196 | + ? -1 |
|
197 | + : $value; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * @param mixed $source |
|
203 | + * @return EE_Base_Class|null |
|
204 | + * @since $VID:$ |
|
205 | + */ |
|
206 | + private function getModel($source) |
|
207 | + { |
|
208 | + // If it comes from a custom connection |
|
209 | + // where the $source is already instantiated. |
|
210 | + if ($source instanceof EE_Base_Class) { |
|
211 | + return $source; |
|
212 | + } |
|
213 | + return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
219 | + * @param array $args The inputArgs on the field |
|
220 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
221 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
222 | + * @return string |
|
223 | + * @throws EE_Error |
|
224 | + * @throws InvalidDataTypeException |
|
225 | + * @throws InvalidInterfaceException |
|
226 | + * @throws UnexpectedEntityException |
|
227 | + * @throws UserError |
|
228 | + * @throws InvalidArgumentException |
|
229 | + * @throws ReflectionException |
|
230 | + * @since $VID:$ |
|
231 | + */ |
|
232 | + public function resolveField($source, $args, AppContext $context, ResolveInfo $info) |
|
233 | + { |
|
234 | + $source = $this->getModel($source); |
|
235 | + if ($source instanceof EE_Base_Class) { |
|
236 | + return $this->field_resolver->resolve($source, $args, $context, $info); |
|
237 | + } |
|
238 | + return null; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * @param mixed $payload The payload returned after mutation |
|
244 | + * @param array $args The inputArgs on the field |
|
245 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
246 | + * @return string |
|
247 | + * @throws EE_Error |
|
248 | + * @throws InvalidDataTypeException |
|
249 | + * @throws InvalidInterfaceException |
|
250 | + * @throws UnexpectedEntityException |
|
251 | + * @throws UserError |
|
252 | + * @throws InvalidArgumentException |
|
253 | + * @throws ReflectionException |
|
254 | + * @since $VID:$ |
|
255 | + */ |
|
256 | + public function resolveFromPayload($payload, $args, AppContext $context) |
|
257 | + { |
|
258 | + if ( empty( $payload['id'] ) || ! absint( $payload['id'] ) ) { |
|
259 | + return null; |
|
260 | + } |
|
261 | + return $this->model->get_one_by_ID($payload['id']); |
|
262 | + } |
|
263 | 263 | } |
264 | 264 | \ No newline at end of file |
@@ -255,7 +255,7 @@ |
||
255 | 255 | */ |
256 | 256 | public function resolveFromPayload($payload, $args, AppContext $context) |
257 | 257 | { |
258 | - if ( empty( $payload['id'] ) || ! absint( $payload['id'] ) ) { |
|
258 | + if (empty($payload['id']) || ! absint($payload['id'])) { |
|
259 | 259 | return null; |
260 | 260 | } |
261 | 261 | return $this->model->get_one_by_ID($payload['id']); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | /** |
28 | 28 | * TypesManager constructor. |
29 | 29 | * |
30 | - * @param TypeCollection|TypeInterface[] $types |
|
30 | + * @param TypeCollection $types |
|
31 | 31 | */ |
32 | 32 | public function __construct(TypeCollection $types) |
33 | 33 | { |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $config = $field->toArray(); |
76 | 76 | if ($field->useForInput()) { |
77 | 77 | // Register input fields for existing mutations. |
78 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
78 | + register_graphql_field('Update'.$typeName.'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create'.$typeName.'Input', $fieldName, $config); |
|
80 | 80 | } |
81 | 81 | if ($field->useForOutput()) { |
82 | 82 | $config['resolve'] = [$type, 'resolveField']; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | $typeName = $type->name(); |
110 | - if (! empty($outputFields)) { |
|
110 | + if ( ! empty($outputFields)) { |
|
111 | 111 | // Register the object type. |
112 | 112 | register_graphql_object_type( |
113 | 113 | $typeName, |
@@ -18,110 +18,110 @@ |
||
18 | 18 | class TypesManager |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var TypeCollection|TypeInterface[] $types |
|
23 | - */ |
|
24 | - private $types; |
|
21 | + /** |
|
22 | + * @var TypeCollection|TypeInterface[] $types |
|
23 | + */ |
|
24 | + private $types; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * TypesManager constructor. |
|
29 | - * |
|
30 | - * @param TypeCollection|TypeInterface[] $types |
|
31 | - */ |
|
32 | - public function __construct(TypeCollection $types) |
|
33 | - { |
|
34 | - $this->types = $types; |
|
35 | - } |
|
27 | + /** |
|
28 | + * TypesManager constructor. |
|
29 | + * |
|
30 | + * @param TypeCollection|TypeInterface[] $types |
|
31 | + */ |
|
32 | + public function __construct(TypeCollection $types) |
|
33 | + { |
|
34 | + $this->types = $types; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->types->loadTypes(); |
|
46 | - add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->types->loadTypes(); |
|
46 | + add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function configureTypes() |
|
54 | - { |
|
55 | - // loop through the collection of types and register their fields |
|
56 | - foreach ($this->types as $type) { |
|
57 | - if ($type->isCustomPostType()) { |
|
58 | - $this->extendCustomPostType($type); |
|
59 | - } else { |
|
60 | - $this->registerType($type); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
50 | + /** |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function configureTypes() |
|
54 | + { |
|
55 | + // loop through the collection of types and register their fields |
|
56 | + foreach ($this->types as $type) { |
|
57 | + if ($type->isCustomPostType()) { |
|
58 | + $this->extendCustomPostType($type); |
|
59 | + } else { |
|
60 | + $this->registerType($type); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param TypeInterface $type |
|
68 | - * @since $VID:$ |
|
69 | - */ |
|
70 | - public function extendCustomPostType(TypeInterface $type) |
|
71 | - { |
|
72 | - $typeName = $type->name(); |
|
73 | - foreach ($type->fields() as $field) { |
|
74 | - $fieldName = $field->name(); |
|
75 | - $config = $field->toArray(); |
|
76 | - if ($field->useForInput()) { |
|
77 | - // Register input fields for existing mutations. |
|
78 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
80 | - } |
|
81 | - if ($field->useForOutput()) { |
|
82 | - $config['resolve'] = [$type, 'resolveField']; |
|
83 | - // Register fields for queries. |
|
84 | - register_graphql_field($typeName, $fieldName, $config); |
|
85 | - } |
|
86 | - } |
|
87 | - if (is_callable([$type, 'extendMutations'])) { |
|
88 | - $type->extendMutations(); |
|
89 | - } |
|
90 | - } |
|
66 | + /** |
|
67 | + * @param TypeInterface $type |
|
68 | + * @since $VID:$ |
|
69 | + */ |
|
70 | + public function extendCustomPostType(TypeInterface $type) |
|
71 | + { |
|
72 | + $typeName = $type->name(); |
|
73 | + foreach ($type->fields() as $field) { |
|
74 | + $fieldName = $field->name(); |
|
75 | + $config = $field->toArray(); |
|
76 | + if ($field->useForInput()) { |
|
77 | + // Register input fields for existing mutations. |
|
78 | + register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
80 | + } |
|
81 | + if ($field->useForOutput()) { |
|
82 | + $config['resolve'] = [$type, 'resolveField']; |
|
83 | + // Register fields for queries. |
|
84 | + register_graphql_field($typeName, $fieldName, $config); |
|
85 | + } |
|
86 | + } |
|
87 | + if (is_callable([$type, 'extendMutations'])) { |
|
88 | + $type->extendMutations(); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @param TypeInterface $type |
|
95 | - * @since $VID:$ |
|
96 | - */ |
|
97 | - public function registerType(TypeInterface $type) |
|
98 | - { |
|
99 | - $outputFields = []; |
|
100 | - $inputFields = []; |
|
101 | - foreach ($type->fields() as $field) { |
|
102 | - $fieldName = $field->name(); |
|
103 | - $config = $field->toArray(); |
|
104 | - if ($field->useForInput()) { |
|
105 | - $inputFields[$fieldName] = $config; |
|
106 | - } |
|
107 | - if ($field->useForOutput()) { |
|
108 | - $config['resolve'] = [$type, 'resolveField']; |
|
109 | - $outputFields[$fieldName] = $config; |
|
110 | - } |
|
111 | - } |
|
112 | - $typeName = $type->name(); |
|
113 | - if (! empty($outputFields)) { |
|
114 | - // Register the object type. |
|
115 | - register_graphql_object_type( |
|
116 | - $typeName, |
|
117 | - [ |
|
118 | - 'description' => $type->description(), |
|
119 | - 'fields' => $outputFields, |
|
120 | - ] |
|
121 | - ); |
|
122 | - } |
|
123 | - if (is_callable([$type, 'registerMutations'])) { |
|
124 | - $type->registerMutations($inputFields); |
|
125 | - } |
|
126 | - } |
|
93 | + /** |
|
94 | + * @param TypeInterface $type |
|
95 | + * @since $VID:$ |
|
96 | + */ |
|
97 | + public function registerType(TypeInterface $type) |
|
98 | + { |
|
99 | + $outputFields = []; |
|
100 | + $inputFields = []; |
|
101 | + foreach ($type->fields() as $field) { |
|
102 | + $fieldName = $field->name(); |
|
103 | + $config = $field->toArray(); |
|
104 | + if ($field->useForInput()) { |
|
105 | + $inputFields[$fieldName] = $config; |
|
106 | + } |
|
107 | + if ($field->useForOutput()) { |
|
108 | + $config['resolve'] = [$type, 'resolveField']; |
|
109 | + $outputFields[$fieldName] = $config; |
|
110 | + } |
|
111 | + } |
|
112 | + $typeName = $type->name(); |
|
113 | + if (! empty($outputFields)) { |
|
114 | + // Register the object type. |
|
115 | + register_graphql_object_type( |
|
116 | + $typeName, |
|
117 | + [ |
|
118 | + 'description' => $type->description(), |
|
119 | + 'fields' => $outputFields, |
|
120 | + ] |
|
121 | + ); |
|
122 | + } |
|
123 | + if (is_callable([$type, 'registerMutations'])) { |
|
124 | + $type->registerMutations($inputFields); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | } |
128 | 128 | \ No newline at end of file |
@@ -20,181 +20,181 @@ |
||
20 | 20 | class Ticket extends TypeBase |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Ticket constructor. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $ticket_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Ticket $ticket_model) |
|
29 | - { |
|
30 | - $this->model = $ticket_model; |
|
31 | - $this->setName('Ticket'); |
|
32 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
33 | - $this->setIsCustomPostType(false); |
|
34 | - parent::__construct(); |
|
35 | - } |
|
23 | + /** |
|
24 | + * Ticket constructor. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $ticket_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Ticket $ticket_model) |
|
29 | + { |
|
30 | + $this->model = $ticket_model; |
|
31 | + $this->setName('Ticket'); |
|
32 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
33 | + $this->setIsCustomPostType(false); |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - protected function getFields() |
|
43 | - { |
|
44 | - return [ |
|
45 | - new GraphQLField( |
|
46 | - 'id', |
|
47 | - ['non_null' => 'Int'], |
|
48 | - 'ID', |
|
49 | - __('Ticket ID', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLField( |
|
52 | - 'name', |
|
53 | - 'String', |
|
54 | - 'name', |
|
55 | - __('Ticket Name', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLField( |
|
58 | - 'description', |
|
59 | - 'String', |
|
60 | - 'description', |
|
61 | - __('Description of Ticket', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLField( |
|
64 | - 'startDate', |
|
65 | - 'String', |
|
66 | - 'start_date', |
|
67 | - __('Start time/date of Ticket', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLField( |
|
70 | - 'endDate', |
|
71 | - 'String', |
|
72 | - 'end_date', |
|
73 | - __('End time/date of Ticket', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLField( |
|
76 | - 'min', |
|
77 | - 'Int', |
|
78 | - 'min', |
|
79 | - __('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLField( |
|
82 | - 'max', |
|
83 | - 'Int', |
|
84 | - 'max', |
|
85 | - __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), |
|
86 | - [$this, 'parseInfiniteValue'] |
|
87 | - ), |
|
88 | - new GraphQLField( |
|
89 | - 'price', |
|
90 | - 'Float', |
|
91 | - 'price', |
|
92 | - __('Final calculated price for ticket', 'event_espresso') |
|
93 | - ), |
|
94 | - new GraphQLField( |
|
95 | - 'sold', |
|
96 | - 'Int', |
|
97 | - 'sold', |
|
98 | - __('Number of this ticket sold', 'event_espresso') |
|
99 | - ), |
|
100 | - new GraphQLField( |
|
101 | - 'quantity', |
|
102 | - 'Int', |
|
103 | - 'qty', |
|
104 | - __('Quantity of this ticket that is available', 'event_espresso'), |
|
105 | - [$this, 'parseInfiniteValue'] |
|
106 | - ), |
|
107 | - new GraphQLField( |
|
108 | - 'reserved', |
|
109 | - 'Int', |
|
110 | - 'reserved', |
|
111 | - __('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso') |
|
112 | - ), |
|
113 | - new GraphQLField( |
|
114 | - 'uses', |
|
115 | - 'Int', |
|
116 | - 'uses', |
|
117 | - __('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
118 | - [$this, 'parseInfiniteValue'] |
|
119 | - ), |
|
120 | - new GraphQLField( |
|
121 | - 'isRequired', |
|
122 | - 'Boolean', |
|
123 | - 'required', |
|
124 | - __('Flag indicating whether this ticket must be purchased with a transaction', 'event_espresso') |
|
125 | - ), |
|
126 | - new GraphQLField( |
|
127 | - 'isTaxable', |
|
128 | - 'Boolean', |
|
129 | - 'taxable', |
|
130 | - __('Flag indicating whether there is tax applied on this ticket', 'event_espresso') |
|
131 | - ), |
|
132 | - new GraphQLField( |
|
133 | - 'isDefault', |
|
134 | - 'Boolean', |
|
135 | - 'is_default', |
|
136 | - __('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
137 | - ), |
|
138 | - new GraphQLField( |
|
139 | - 'order', |
|
140 | - 'Int', |
|
141 | - 'order', |
|
142 | - __('The order in which the Datetime is displayed', 'event_espresso') |
|
143 | - ), |
|
144 | - new GraphQLField( |
|
145 | - 'row', |
|
146 | - 'Int', |
|
147 | - 'row', |
|
148 | - __('How tickets are displayed in the ui', 'event_espresso') |
|
149 | - ), |
|
150 | - new GraphQLOutputField( |
|
151 | - 'wpUser', |
|
152 | - 'User', |
|
153 | - null, |
|
154 | - __('Ticket Creator', 'event_espresso') |
|
155 | - ), |
|
156 | - new GraphQLInputField( |
|
157 | - 'wpUser', |
|
158 | - 'Int', |
|
159 | - null, |
|
160 | - __('Ticket Creator ID', 'event_espresso') |
|
161 | - ), |
|
162 | - new GraphQLOutputField( |
|
163 | - 'parent', |
|
164 | - 'Ticket', |
|
165 | - null, |
|
166 | - __('The parent ticket of the current ticket', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLInputField( |
|
169 | - 'parent', |
|
170 | - 'Int', |
|
171 | - null, |
|
172 | - __('The parent ticket ID', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLField( |
|
175 | - 'reverseCalculate', |
|
176 | - 'Boolean', |
|
177 | - 'reverse_calculate', |
|
178 | - __('Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLField( |
|
181 | - 'isFree', |
|
182 | - 'Boolean', |
|
183 | - 'is_free', |
|
184 | - __('Flag indicating whether the ticket is free.', 'event_espresso') |
|
185 | - ), |
|
186 | - new GraphQLOutputField( |
|
187 | - 'Event', |
|
188 | - 'Event', |
|
189 | - null, |
|
190 | - __('Event of the ticket.', 'event_espresso') |
|
191 | - ), |
|
192 | - new GraphQLInputField( |
|
193 | - 'event', |
|
194 | - 'Int', |
|
195 | - null, |
|
196 | - __('Event ID of the ticket.', 'event_espresso') |
|
197 | - ), |
|
198 | - ]; |
|
199 | - } |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + protected function getFields() |
|
43 | + { |
|
44 | + return [ |
|
45 | + new GraphQLField( |
|
46 | + 'id', |
|
47 | + ['non_null' => 'Int'], |
|
48 | + 'ID', |
|
49 | + __('Ticket ID', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLField( |
|
52 | + 'name', |
|
53 | + 'String', |
|
54 | + 'name', |
|
55 | + __('Ticket Name', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLField( |
|
58 | + 'description', |
|
59 | + 'String', |
|
60 | + 'description', |
|
61 | + __('Description of Ticket', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLField( |
|
64 | + 'startDate', |
|
65 | + 'String', |
|
66 | + 'start_date', |
|
67 | + __('Start time/date of Ticket', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLField( |
|
70 | + 'endDate', |
|
71 | + 'String', |
|
72 | + 'end_date', |
|
73 | + __('End time/date of Ticket', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLField( |
|
76 | + 'min', |
|
77 | + 'Int', |
|
78 | + 'min', |
|
79 | + __('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLField( |
|
82 | + 'max', |
|
83 | + 'Int', |
|
84 | + 'max', |
|
85 | + __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), |
|
86 | + [$this, 'parseInfiniteValue'] |
|
87 | + ), |
|
88 | + new GraphQLField( |
|
89 | + 'price', |
|
90 | + 'Float', |
|
91 | + 'price', |
|
92 | + __('Final calculated price for ticket', 'event_espresso') |
|
93 | + ), |
|
94 | + new GraphQLField( |
|
95 | + 'sold', |
|
96 | + 'Int', |
|
97 | + 'sold', |
|
98 | + __('Number of this ticket sold', 'event_espresso') |
|
99 | + ), |
|
100 | + new GraphQLField( |
|
101 | + 'quantity', |
|
102 | + 'Int', |
|
103 | + 'qty', |
|
104 | + __('Quantity of this ticket that is available', 'event_espresso'), |
|
105 | + [$this, 'parseInfiniteValue'] |
|
106 | + ), |
|
107 | + new GraphQLField( |
|
108 | + 'reserved', |
|
109 | + 'Int', |
|
110 | + 'reserved', |
|
111 | + __('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso') |
|
112 | + ), |
|
113 | + new GraphQLField( |
|
114 | + 'uses', |
|
115 | + 'Int', |
|
116 | + 'uses', |
|
117 | + __('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
118 | + [$this, 'parseInfiniteValue'] |
|
119 | + ), |
|
120 | + new GraphQLField( |
|
121 | + 'isRequired', |
|
122 | + 'Boolean', |
|
123 | + 'required', |
|
124 | + __('Flag indicating whether this ticket must be purchased with a transaction', 'event_espresso') |
|
125 | + ), |
|
126 | + new GraphQLField( |
|
127 | + 'isTaxable', |
|
128 | + 'Boolean', |
|
129 | + 'taxable', |
|
130 | + __('Flag indicating whether there is tax applied on this ticket', 'event_espresso') |
|
131 | + ), |
|
132 | + new GraphQLField( |
|
133 | + 'isDefault', |
|
134 | + 'Boolean', |
|
135 | + 'is_default', |
|
136 | + __('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
137 | + ), |
|
138 | + new GraphQLField( |
|
139 | + 'order', |
|
140 | + 'Int', |
|
141 | + 'order', |
|
142 | + __('The order in which the Datetime is displayed', 'event_espresso') |
|
143 | + ), |
|
144 | + new GraphQLField( |
|
145 | + 'row', |
|
146 | + 'Int', |
|
147 | + 'row', |
|
148 | + __('How tickets are displayed in the ui', 'event_espresso') |
|
149 | + ), |
|
150 | + new GraphQLOutputField( |
|
151 | + 'wpUser', |
|
152 | + 'User', |
|
153 | + null, |
|
154 | + __('Ticket Creator', 'event_espresso') |
|
155 | + ), |
|
156 | + new GraphQLInputField( |
|
157 | + 'wpUser', |
|
158 | + 'Int', |
|
159 | + null, |
|
160 | + __('Ticket Creator ID', 'event_espresso') |
|
161 | + ), |
|
162 | + new GraphQLOutputField( |
|
163 | + 'parent', |
|
164 | + 'Ticket', |
|
165 | + null, |
|
166 | + __('The parent ticket of the current ticket', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLInputField( |
|
169 | + 'parent', |
|
170 | + 'Int', |
|
171 | + null, |
|
172 | + __('The parent ticket ID', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLField( |
|
175 | + 'reverseCalculate', |
|
176 | + 'Boolean', |
|
177 | + 'reverse_calculate', |
|
178 | + __('Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLField( |
|
181 | + 'isFree', |
|
182 | + 'Boolean', |
|
183 | + 'is_free', |
|
184 | + __('Flag indicating whether the ticket is free.', 'event_espresso') |
|
185 | + ), |
|
186 | + new GraphQLOutputField( |
|
187 | + 'Event', |
|
188 | + 'Event', |
|
189 | + null, |
|
190 | + __('Event of the ticket.', 'event_espresso') |
|
191 | + ), |
|
192 | + new GraphQLInputField( |
|
193 | + 'event', |
|
194 | + 'Int', |
|
195 | + null, |
|
196 | + __('Event ID of the ticket.', 'event_espresso') |
|
197 | + ), |
|
198 | + ]; |
|
199 | + } |
|
200 | 200 | } |
201 | 201 | \ No newline at end of file |
@@ -20,65 +20,65 @@ |
||
20 | 20 | class State extends TypeBase |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * State constructor. |
|
25 | - * |
|
26 | - * @param EEM_State $state_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_State $state_model) |
|
29 | - { |
|
30 | - $this->model = $state_model; |
|
31 | - $this->setName('State'); |
|
32 | - $this->setDescription(__('A state', 'event_espresso')); |
|
33 | - $this->setIsCustomPostType(false); |
|
23 | + /** |
|
24 | + * State constructor. |
|
25 | + * |
|
26 | + * @param EEM_State $state_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_State $state_model) |
|
29 | + { |
|
30 | + $this->model = $state_model; |
|
31 | + $this->setName('State'); |
|
32 | + $this->setDescription(__('A state', 'event_espresso')); |
|
33 | + $this->setIsCustomPostType(false); |
|
34 | 34 | |
35 | - parent::__construct(); |
|
36 | - } |
|
35 | + parent::__construct(); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return GraphQLFieldInterface[] |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function getFields() |
|
44 | - { |
|
45 | - return [ |
|
46 | - new GraphQLField( |
|
47 | - 'id', |
|
48 | - ['non_null' => 'Int'], |
|
49 | - 'ID', |
|
50 | - __('State ID', 'event_espresso') |
|
51 | - ), |
|
52 | - new GraphQLField( |
|
53 | - 'abbreviation', |
|
54 | - 'String', |
|
55 | - 'abbrev', |
|
56 | - __('State Abbreviation', 'event_espresso') |
|
57 | - ), |
|
58 | - new GraphQLField( |
|
59 | - 'name', |
|
60 | - 'String', |
|
61 | - 'name', |
|
62 | - __('State Name', 'event_espresso') |
|
63 | - ), |
|
64 | - new GraphQLField( |
|
65 | - 'isActive', |
|
66 | - 'Boolean', |
|
67 | - 'active', |
|
68 | - __('State Active Flag', 'event_espresso') |
|
69 | - ), |
|
70 | - new GraphQLOutputField( |
|
71 | - 'country', |
|
72 | - 'Country', |
|
73 | - null, |
|
74 | - __('Country for the state', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLInputField( |
|
77 | - 'country', |
|
78 | - 'String', |
|
79 | - null, |
|
80 | - __('Country ISO Code', 'event_espresso') |
|
81 | - ), |
|
82 | - ]; |
|
83 | - } |
|
39 | + /** |
|
40 | + * @return GraphQLFieldInterface[] |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function getFields() |
|
44 | + { |
|
45 | + return [ |
|
46 | + new GraphQLField( |
|
47 | + 'id', |
|
48 | + ['non_null' => 'Int'], |
|
49 | + 'ID', |
|
50 | + __('State ID', 'event_espresso') |
|
51 | + ), |
|
52 | + new GraphQLField( |
|
53 | + 'abbreviation', |
|
54 | + 'String', |
|
55 | + 'abbrev', |
|
56 | + __('State Abbreviation', 'event_espresso') |
|
57 | + ), |
|
58 | + new GraphQLField( |
|
59 | + 'name', |
|
60 | + 'String', |
|
61 | + 'name', |
|
62 | + __('State Name', 'event_espresso') |
|
63 | + ), |
|
64 | + new GraphQLField( |
|
65 | + 'isActive', |
|
66 | + 'Boolean', |
|
67 | + 'active', |
|
68 | + __('State Active Flag', 'event_espresso') |
|
69 | + ), |
|
70 | + new GraphQLOutputField( |
|
71 | + 'country', |
|
72 | + 'Country', |
|
73 | + null, |
|
74 | + __('Country for the state', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLInputField( |
|
77 | + 'country', |
|
78 | + 'String', |
|
79 | + null, |
|
80 | + __('Country ISO Code', 'event_espresso') |
|
81 | + ), |
|
82 | + ]; |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -18,40 +18,40 @@ |
||
18 | 18 | class ConnectionsManager |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var ConnectionCollection|ConnectionInterface[] $connections |
|
23 | - */ |
|
24 | - private $connections; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * ConnectionsManager constructor. |
|
29 | - * |
|
30 | - * @param ConnectionCollection|ConnectionInterface[] $connections |
|
31 | - */ |
|
32 | - public function __construct(ConnectionCollection $connections) |
|
33 | - { |
|
34 | - $this->connections = $connections; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->connections->loadConnections(); |
|
46 | - add_action('graphql_register_types', [$this, 'registerConnections'], 20); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - public function registerConnections() |
|
51 | - { |
|
52 | - // loop through the collection of types and register their fields |
|
53 | - foreach ($this->connections as $connection) { |
|
54 | - register_graphql_connection($connection->config()); |
|
55 | - } |
|
56 | - } |
|
21 | + /** |
|
22 | + * @var ConnectionCollection|ConnectionInterface[] $connections |
|
23 | + */ |
|
24 | + private $connections; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * ConnectionsManager constructor. |
|
29 | + * |
|
30 | + * @param ConnectionCollection|ConnectionInterface[] $connections |
|
31 | + */ |
|
32 | + public function __construct(ConnectionCollection $connections) |
|
33 | + { |
|
34 | + $this->connections = $connections; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->connections->loadConnections(); |
|
46 | + add_action('graphql_register_types', [$this, 'registerConnections'], 20); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + public function registerConnections() |
|
51 | + { |
|
52 | + // loop through the collection of types and register their fields |
|
53 | + foreach ($this->connections as $connection) { |
|
54 | + register_graphql_connection($connection->config()); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -25,79 +25,79 @@ |
||
25 | 25 | interface TypeInterface |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function name(); |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function description(); |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
42 | - * @since $VID:$ |
|
43 | - */ |
|
44 | - public function fields(); |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Creates a key map for internal resolver. |
|
49 | - * |
|
50 | - * @return array |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function getFieldsForResolver(); |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function isCustomPostType(); |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @param int $value |
|
64 | - * @return int |
|
65 | - * @since $VID:$ |
|
66 | - */ |
|
67 | - public function parseInfiniteValue($value); |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
72 | - * @param array $args The inputArgs on the field |
|
73 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
74 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
75 | - * @return string |
|
76 | - * @throws EE_Error |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidInterfaceException |
|
79 | - * @throws UnexpectedEntityException |
|
80 | - * @throws UserError |
|
81 | - * @throws InvalidArgumentException |
|
82 | - * @throws ReflectionException |
|
83 | - * @since $VID:$ |
|
84 | - */ |
|
85 | - public function resolveField($source, $args, AppContext $context, ResolveInfo $info); |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param mixed $payload The payload returned after mutation |
|
90 | - * @param array $args The inputArgs on the field |
|
91 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
92 | - * @return string |
|
93 | - * @throws EE_Error |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws UnexpectedEntityException |
|
97 | - * @throws UserError |
|
98 | - * @throws InvalidArgumentException |
|
99 | - * @throws ReflectionException |
|
100 | - * @since $VID:$ |
|
101 | - */ |
|
102 | - public function resolveFromPayload($payload, $args, AppContext $context); |
|
28 | + /** |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function name(); |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function description(); |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
42 | + * @since $VID:$ |
|
43 | + */ |
|
44 | + public function fields(); |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Creates a key map for internal resolver. |
|
49 | + * |
|
50 | + * @return array |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function getFieldsForResolver(); |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function isCustomPostType(); |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @param int $value |
|
64 | + * @return int |
|
65 | + * @since $VID:$ |
|
66 | + */ |
|
67 | + public function parseInfiniteValue($value); |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
72 | + * @param array $args The inputArgs on the field |
|
73 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
74 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
75 | + * @return string |
|
76 | + * @throws EE_Error |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidInterfaceException |
|
79 | + * @throws UnexpectedEntityException |
|
80 | + * @throws UserError |
|
81 | + * @throws InvalidArgumentException |
|
82 | + * @throws ReflectionException |
|
83 | + * @since $VID:$ |
|
84 | + */ |
|
85 | + public function resolveField($source, $args, AppContext $context, ResolveInfo $info); |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param mixed $payload The payload returned after mutation |
|
90 | + * @param array $args The inputArgs on the field |
|
91 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
92 | + * @return string |
|
93 | + * @throws EE_Error |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws UnexpectedEntityException |
|
97 | + * @throws UserError |
|
98 | + * @throws InvalidArgumentException |
|
99 | + * @throws ReflectionException |
|
100 | + * @since $VID:$ |
|
101 | + */ |
|
102 | + public function resolveFromPayload($payload, $args, AppContext $context); |
|
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -21,86 +21,86 @@ |
||
21 | 21 | class TypeCollection extends Collection |
22 | 22 | { |
23 | 23 | |
24 | - const COLLECTION_NAME = 'espresso_graphql_types'; |
|
24 | + const COLLECTION_NAME = 'espresso_graphql_types'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var CollectionLoader $loader |
|
28 | - */ |
|
29 | - protected $loader; |
|
26 | + /** |
|
27 | + * @var CollectionLoader $loader |
|
28 | + */ |
|
29 | + protected $loader; |
|
30 | 30 | |
31 | - /** |
|
32 | - * TypeCollection constructor |
|
33 | - * |
|
34 | - * @throws InvalidInterfaceException |
|
35 | - */ |
|
36 | - public function __construct() |
|
37 | - { |
|
38 | - parent::__construct( |
|
39 | - 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
40 | - TypeCollection::COLLECTION_NAME |
|
41 | - ); |
|
42 | - } |
|
31 | + /** |
|
32 | + * TypeCollection constructor |
|
33 | + * |
|
34 | + * @throws InvalidInterfaceException |
|
35 | + */ |
|
36 | + public function __construct() |
|
37 | + { |
|
38 | + parent::__construct( |
|
39 | + 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
40 | + TypeCollection::COLLECTION_NAME |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @throws CollectionDetailsException |
|
47 | - * @throws CollectionLoaderException |
|
48 | - * @since $VID:$ |
|
49 | - */ |
|
50 | - private function loadCollection() |
|
51 | - { |
|
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
53 | - $this->loader = new CollectionLoader( |
|
54 | - new CollectionDetails( |
|
55 | - // collection name |
|
56 | - TypeCollection::COLLECTION_NAME, |
|
57 | - // collection interface |
|
58 | - 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
59 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
60 | - apply_filters( |
|
61 | - 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
62 | - ['EventEspresso\core\domain\services\graphql\types'] |
|
63 | - ), |
|
64 | - // filepaths to classes to add |
|
65 | - array(), |
|
66 | - // file mask to use if parsing folder for files to add |
|
67 | - '', |
|
68 | - // what to use as identifier for collection entities |
|
69 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
70 | - CollectionDetails::ID_CLASS_NAME |
|
71 | - ), |
|
72 | - $this |
|
73 | - ); |
|
74 | - } |
|
75 | - } |
|
45 | + /** |
|
46 | + * @throws CollectionDetailsException |
|
47 | + * @throws CollectionLoaderException |
|
48 | + * @since $VID:$ |
|
49 | + */ |
|
50 | + private function loadCollection() |
|
51 | + { |
|
52 | + if (! $this->loader instanceof CollectionLoader) { |
|
53 | + $this->loader = new CollectionLoader( |
|
54 | + new CollectionDetails( |
|
55 | + // collection name |
|
56 | + TypeCollection::COLLECTION_NAME, |
|
57 | + // collection interface |
|
58 | + 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
59 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
60 | + apply_filters( |
|
61 | + 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
62 | + ['EventEspresso\core\domain\services\graphql\types'] |
|
63 | + ), |
|
64 | + // filepaths to classes to add |
|
65 | + array(), |
|
66 | + // file mask to use if parsing folder for files to add |
|
67 | + '', |
|
68 | + // what to use as identifier for collection entities |
|
69 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
70 | + CollectionDetails::ID_CLASS_NAME |
|
71 | + ), |
|
72 | + $this |
|
73 | + ); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * @return CollectionInterface |
|
80 | - * @throws CollectionDetailsException |
|
81 | - * @throws CollectionLoaderException |
|
82 | - * @since $VID:$ |
|
83 | - */ |
|
84 | - public function loadTypes() |
|
85 | - { |
|
86 | - $this->loadCollection(); |
|
87 | - return $this->loader->getCollection(); |
|
88 | - } |
|
78 | + /** |
|
79 | + * @return CollectionInterface |
|
80 | + * @throws CollectionDetailsException |
|
81 | + * @throws CollectionLoaderException |
|
82 | + * @since $VID:$ |
|
83 | + */ |
|
84 | + public function loadTypes() |
|
85 | + { |
|
86 | + $this->loadCollection(); |
|
87 | + return $this->loader->getCollection(); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * getIdentifier |
|
93 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
94 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
95 | - * |
|
96 | - * @param $object |
|
97 | - * @param mixed $identifier |
|
98 | - * @return bool |
|
99 | - */ |
|
100 | - public function getIdentifier($object, $identifier = null) |
|
101 | - { |
|
102 | - return ! empty($identifier) |
|
103 | - ? $identifier |
|
104 | - : get_class($object); |
|
105 | - } |
|
91 | + /** |
|
92 | + * getIdentifier |
|
93 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
94 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
95 | + * |
|
96 | + * @param $object |
|
97 | + * @param mixed $identifier |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | + public function getIdentifier($object, $identifier = null) |
|
101 | + { |
|
102 | + return ! empty($identifier) |
|
103 | + ? $identifier |
|
104 | + : get_class($object); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | \ No newline at end of file |