@@ -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']; |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | $fieldName = $field->name(); |
103 | 103 | $config = $field->toArray(); |
104 | 104 | if ($field->useForInput()) { |
105 | - $inputFields[ $fieldName ] = $config; |
|
105 | + $inputFields[$fieldName] = $config; |
|
106 | 106 | } |
107 | 107 | if ($field->useForOutput()) { |
108 | 108 | $config['resolve'] = [$type, 'resolveField']; |
109 | - $outputFields[ $fieldName ] = $config; |
|
109 | + $outputFields[$fieldName] = $config; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $typeName = $type->name(); |
113 | - if (! empty($outputFields)) { |
|
113 | + if ( ! empty($outputFields)) { |
|
114 | 114 | // Register the object type. |
115 | 115 | register_graphql_object_type( |
116 | 116 | $typeName, |
@@ -17,110 +17,110 @@ |
||
17 | 17 | */ |
18 | 18 | class TypesManager implements GQLManagerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var TypeCollection|TypeInterface[] $types |
|
22 | - */ |
|
23 | - private $types; |
|
20 | + /** |
|
21 | + * @var TypeCollection|TypeInterface[] $types |
|
22 | + */ |
|
23 | + private $types; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * TypesManager constructor. |
|
28 | - * |
|
29 | - * @param TypeCollection|TypeInterface[] $types |
|
30 | - */ |
|
31 | - public function __construct(TypeCollection $types) |
|
32 | - { |
|
33 | - $this->types = $types; |
|
34 | - } |
|
26 | + /** |
|
27 | + * TypesManager constructor. |
|
28 | + * |
|
29 | + * @param TypeCollection|TypeInterface[] $types |
|
30 | + */ |
|
31 | + public function __construct(TypeCollection $types) |
|
32 | + { |
|
33 | + $this->types = $types; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @throws CollectionDetailsException |
|
39 | - * @throws CollectionLoaderException |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function init() |
|
43 | - { |
|
44 | - $this->types->loadTypes(); |
|
45 | - add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
46 | - } |
|
37 | + /** |
|
38 | + * @throws CollectionDetailsException |
|
39 | + * @throws CollectionLoaderException |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function init() |
|
43 | + { |
|
44 | + $this->types->loadTypes(); |
|
45 | + add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @since $VID:$ |
|
51 | - */ |
|
52 | - public function configureTypes() |
|
53 | - { |
|
54 | - // loop through the collection of types and register their fields |
|
55 | - foreach ($this->types as $type) { |
|
56 | - if ($type->isCustomPostType()) { |
|
57 | - $this->extendCustomPostType($type); |
|
58 | - } else { |
|
59 | - $this->registerType($type); |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
49 | + /** |
|
50 | + * @since $VID:$ |
|
51 | + */ |
|
52 | + public function configureTypes() |
|
53 | + { |
|
54 | + // loop through the collection of types and register their fields |
|
55 | + foreach ($this->types as $type) { |
|
56 | + if ($type->isCustomPostType()) { |
|
57 | + $this->extendCustomPostType($type); |
|
58 | + } else { |
|
59 | + $this->registerType($type); |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @param TypeInterface $type |
|
67 | - * @since $VID:$ |
|
68 | - */ |
|
69 | - public function extendCustomPostType(TypeInterface $type) |
|
70 | - { |
|
71 | - $typeName = $type->name(); |
|
72 | - foreach ($type->fields() as $field) { |
|
73 | - $fieldName = $field->name(); |
|
74 | - $config = $field->toArray(); |
|
75 | - if ($field->useForInput()) { |
|
76 | - // Register input fields for existing mutations. |
|
77 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
78 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
79 | - } |
|
80 | - if ($field->useForOutput()) { |
|
81 | - $config['resolve'] = [$type, 'resolveField']; |
|
82 | - // Register fields for queries. |
|
83 | - register_graphql_field($typeName, $fieldName, $config); |
|
84 | - } |
|
85 | - } |
|
86 | - if (is_callable([$type, 'extendMutations'])) { |
|
87 | - $type->extendMutations(); |
|
88 | - } |
|
89 | - } |
|
65 | + /** |
|
66 | + * @param TypeInterface $type |
|
67 | + * @since $VID:$ |
|
68 | + */ |
|
69 | + public function extendCustomPostType(TypeInterface $type) |
|
70 | + { |
|
71 | + $typeName = $type->name(); |
|
72 | + foreach ($type->fields() as $field) { |
|
73 | + $fieldName = $field->name(); |
|
74 | + $config = $field->toArray(); |
|
75 | + if ($field->useForInput()) { |
|
76 | + // Register input fields for existing mutations. |
|
77 | + register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
78 | + register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
79 | + } |
|
80 | + if ($field->useForOutput()) { |
|
81 | + $config['resolve'] = [$type, 'resolveField']; |
|
82 | + // Register fields for queries. |
|
83 | + register_graphql_field($typeName, $fieldName, $config); |
|
84 | + } |
|
85 | + } |
|
86 | + if (is_callable([$type, 'extendMutations'])) { |
|
87 | + $type->extendMutations(); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @param TypeInterface $type |
|
94 | - * @since $VID:$ |
|
95 | - */ |
|
96 | - public function registerType(TypeInterface $type) |
|
97 | - { |
|
98 | - $outputFields = []; |
|
99 | - $inputFields = []; |
|
100 | - foreach ($type->fields() as $field) { |
|
101 | - $fieldName = $field->name(); |
|
102 | - $config = $field->toArray(); |
|
103 | - if ($field->useForInput()) { |
|
104 | - $inputFields[ $fieldName ] = $config; |
|
105 | - } |
|
106 | - if ($field->useForOutput()) { |
|
107 | - $config['resolve'] = [$type, 'resolveField']; |
|
108 | - $outputFields[ $fieldName ] = $config; |
|
109 | - } |
|
110 | - } |
|
111 | - $typeName = $type->name(); |
|
112 | - if (! empty($outputFields)) { |
|
113 | - // Register the object type. |
|
114 | - register_graphql_object_type( |
|
115 | - $typeName, |
|
116 | - [ |
|
117 | - 'description' => $type->description(), |
|
118 | - 'fields' => $outputFields, |
|
119 | - ] |
|
120 | - ); |
|
121 | - } |
|
122 | - if (is_callable([$type, 'registerMutations'])) { |
|
123 | - $type->registerMutations($inputFields); |
|
124 | - } |
|
125 | - } |
|
92 | + /** |
|
93 | + * @param TypeInterface $type |
|
94 | + * @since $VID:$ |
|
95 | + */ |
|
96 | + public function registerType(TypeInterface $type) |
|
97 | + { |
|
98 | + $outputFields = []; |
|
99 | + $inputFields = []; |
|
100 | + foreach ($type->fields() as $field) { |
|
101 | + $fieldName = $field->name(); |
|
102 | + $config = $field->toArray(); |
|
103 | + if ($field->useForInput()) { |
|
104 | + $inputFields[ $fieldName ] = $config; |
|
105 | + } |
|
106 | + if ($field->useForOutput()) { |
|
107 | + $config['resolve'] = [$type, 'resolveField']; |
|
108 | + $outputFields[ $fieldName ] = $config; |
|
109 | + } |
|
110 | + } |
|
111 | + $typeName = $type->name(); |
|
112 | + if (! empty($outputFields)) { |
|
113 | + // Register the object type. |
|
114 | + register_graphql_object_type( |
|
115 | + $typeName, |
|
116 | + [ |
|
117 | + 'description' => $type->description(), |
|
118 | + 'fields' => $outputFields, |
|
119 | + ] |
|
120 | + ); |
|
121 | + } |
|
122 | + if (is_callable([$type, 'registerMutations'])) { |
|
123 | + $type->registerMutations($inputFields); |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |
@@ -155,7 +155,7 @@ |
||
155 | 155 | $fields = []; |
156 | 156 | foreach ($this->fields() as $field) { |
157 | 157 | if ($field->useForOutput()) { |
158 | - $fields[ $field->name() ] = $field; |
|
158 | + $fields[$field->name()] = $field; |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | return $fields; |
@@ -34,270 +34,270 @@ |
||
34 | 34 | */ |
35 | 35 | abstract class TypeBase implements TypeInterface |
36 | 36 | { |
37 | - /** |
|
38 | - * @var string $namespace The graphql namespace/prefix. |
|
39 | - */ |
|
40 | - protected $namespace = 'Espresso'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EEM_Base $model |
|
44 | - */ |
|
45 | - protected $model; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string $name |
|
49 | - */ |
|
50 | - protected $name = ''; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string $description |
|
54 | - */ |
|
55 | - protected $description = ''; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var GraphQLFieldInterface[] $fields |
|
59 | - */ |
|
60 | - protected $fields = []; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var array $graphql_to_model_map |
|
64 | - */ |
|
65 | - protected $graphql_to_model_map = []; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var FieldResolver $field_resolver |
|
69 | - */ |
|
70 | - protected $field_resolver; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var bool $is_custom_post_type |
|
74 | - */ |
|
75 | - protected $is_custom_post_type = false; |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * TypeBase constructor. |
|
80 | - * |
|
81 | - * @param EEM_Base|null $model |
|
82 | - */ |
|
83 | - public function __construct(EEM_Base $model = null) |
|
84 | - { |
|
85 | - $this->model = $model; |
|
86 | - $this->setFields($this->getFields()); |
|
87 | - $this->field_resolver = new FieldResolver( |
|
88 | - $this->model, |
|
89 | - $this->getFieldsForResolver() |
|
90 | - ); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * @return GraphQLFieldInterface[] |
|
96 | - * @since $VID:$ |
|
97 | - */ |
|
98 | - abstract protected function getFields(): array; |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public function name(): string |
|
105 | - { |
|
106 | - return $this->name; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @param string $name |
|
112 | - */ |
|
113 | - protected function setName(string $name) |
|
114 | - { |
|
115 | - $this->name = $name; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function description(): string |
|
123 | - { |
|
124 | - return $this->description; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param string $description |
|
130 | - */ |
|
131 | - protected function setDescription(string $description) |
|
132 | - { |
|
133 | - $this->description = $description; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @return GraphQLFieldInterface[] |
|
139 | - * @since $VID:$ |
|
140 | - */ |
|
141 | - public function fields(): array |
|
142 | - { |
|
143 | - return (array) $this->fields; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @param GraphQLFieldInterface[] $fields |
|
149 | - */ |
|
150 | - protected function setFields(array $fields) |
|
151 | - { |
|
152 | - foreach ($fields as $field) { |
|
153 | - if ($field instanceof GraphQLField) { |
|
154 | - $this->fields[] = $field; |
|
155 | - } |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * Creates a key map for internal resolver. |
|
162 | - * |
|
163 | - * @return array |
|
164 | - * @since $VID:$ |
|
165 | - */ |
|
166 | - public function getFieldsForResolver(): array |
|
167 | - { |
|
168 | - $fields = []; |
|
169 | - foreach ($this->fields() as $field) { |
|
170 | - if ($field->useForOutput()) { |
|
171 | - $fields[ $field->name() ] = $field; |
|
172 | - } |
|
173 | - } |
|
174 | - return $fields; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @return bool |
|
180 | - */ |
|
181 | - public function isCustomPostType(): bool |
|
182 | - { |
|
183 | - return $this->is_custom_post_type; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * @param bool $is_custom_post_type |
|
189 | - */ |
|
190 | - protected function setIsCustomPostType(bool $is_custom_post_type) |
|
191 | - { |
|
192 | - $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * @param int|float $value |
|
198 | - * @return int |
|
199 | - * @since $VID:$ |
|
200 | - */ |
|
201 | - public function parseInfiniteValue($value): int |
|
202 | - { |
|
203 | - $value = trim($value); |
|
204 | - return $value === null |
|
205 | - || $value === '' |
|
206 | - || $value === '∞' |
|
207 | - || $value === 'INF' |
|
208 | - || $value === INF |
|
209 | - || $value === EE_INF |
|
210 | - || is_infinite((float) $value) |
|
211 | - ? -1 |
|
212 | - : $value; |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * @param mixed $source |
|
218 | - * @return EE_Base_Class|null |
|
219 | - * @throws EE_Error |
|
220 | - */ |
|
221 | - private function getModel($source): ?EE_Base_Class |
|
222 | - { |
|
223 | - // If it comes from a custom connection |
|
224 | - // where the $source is already instantiated. |
|
225 | - if ($source instanceof EE_Base_Class) { |
|
226 | - return $source; |
|
227 | - } |
|
228 | - return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
234 | - * @param array $args The inputArgs on the field |
|
235 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
236 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
237 | - * @return EE_Base_Class|Deferred|string|null |
|
238 | - * @throws EE_Error |
|
239 | - * @throws InvalidDataTypeException |
|
240 | - * @throws InvalidInterfaceException |
|
241 | - * @throws UnexpectedEntityException |
|
242 | - * @throws UserError |
|
243 | - * @throws InvalidArgumentException |
|
244 | - * @throws ReflectionException |
|
245 | - * @since $VID:$ |
|
246 | - */ |
|
247 | - public function resolveField($source, array $args, AppContext $context, ResolveInfo $info) |
|
248 | - { |
|
249 | - $source = $source instanceof RootQuery ? $source : $this->getModel($source); |
|
250 | - |
|
251 | - return $this->field_resolver->resolve($source, $args, $context, $info); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @param mixed $payload The payload returned after mutation |
|
257 | - * @param array $args The inputArgs on the field |
|
258 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
259 | - * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null |
|
260 | - * @throws EE_Error |
|
261 | - */ |
|
262 | - public function resolveFromPayload($payload, array $args, AppContext $context) |
|
263 | - { |
|
264 | - if (empty($payload['id'])) { |
|
265 | - return null; |
|
266 | - } |
|
267 | - return $this->model->get_one_by_ID($payload['id']); |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * Prepares a datetime value in ISO8601/RFC3339 format. |
|
273 | - * It is assumed that the value of $datetime is in the format |
|
274 | - * returned by EE_Base_Class::get_format(). |
|
275 | - * |
|
276 | - * @param string $datetime The datetime value. |
|
277 | - * @param EE_Base_Class $source The source object. |
|
278 | - * @return string ISO8601/RFC3339 formatted datetime. |
|
279 | - */ |
|
280 | - public function formatDatetime(string $datetime, EE_Base_Class $source): string |
|
281 | - { |
|
282 | - $format = $source->get_format(); |
|
283 | - // create date object based on local timezone |
|
284 | - $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone())); |
|
285 | - // change the timezone to UTC |
|
286 | - $datetime->setTimezone(new DateTimeZone('UTC')); |
|
287 | - |
|
288 | - return $datetime->format(DateTime::RFC3339); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * Converts an object to JSON. The object must have a "toJson" method. |
|
294 | - * |
|
295 | - * @param string $object The object/value. |
|
296 | - * @param EE_Base_Class $source The source object. |
|
297 | - * @return string JSON representation of the object. |
|
298 | - */ |
|
299 | - public function toJson(JsonableInterface $object, EE_Base_Class $source): string |
|
300 | - { |
|
301 | - return $object->toJson(); |
|
302 | - } |
|
37 | + /** |
|
38 | + * @var string $namespace The graphql namespace/prefix. |
|
39 | + */ |
|
40 | + protected $namespace = 'Espresso'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EEM_Base $model |
|
44 | + */ |
|
45 | + protected $model; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string $name |
|
49 | + */ |
|
50 | + protected $name = ''; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string $description |
|
54 | + */ |
|
55 | + protected $description = ''; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var GraphQLFieldInterface[] $fields |
|
59 | + */ |
|
60 | + protected $fields = []; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var array $graphql_to_model_map |
|
64 | + */ |
|
65 | + protected $graphql_to_model_map = []; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var FieldResolver $field_resolver |
|
69 | + */ |
|
70 | + protected $field_resolver; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var bool $is_custom_post_type |
|
74 | + */ |
|
75 | + protected $is_custom_post_type = false; |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * TypeBase constructor. |
|
80 | + * |
|
81 | + * @param EEM_Base|null $model |
|
82 | + */ |
|
83 | + public function __construct(EEM_Base $model = null) |
|
84 | + { |
|
85 | + $this->model = $model; |
|
86 | + $this->setFields($this->getFields()); |
|
87 | + $this->field_resolver = new FieldResolver( |
|
88 | + $this->model, |
|
89 | + $this->getFieldsForResolver() |
|
90 | + ); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * @return GraphQLFieldInterface[] |
|
96 | + * @since $VID:$ |
|
97 | + */ |
|
98 | + abstract protected function getFields(): array; |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public function name(): string |
|
105 | + { |
|
106 | + return $this->name; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @param string $name |
|
112 | + */ |
|
113 | + protected function setName(string $name) |
|
114 | + { |
|
115 | + $this->name = $name; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function description(): string |
|
123 | + { |
|
124 | + return $this->description; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param string $description |
|
130 | + */ |
|
131 | + protected function setDescription(string $description) |
|
132 | + { |
|
133 | + $this->description = $description; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @return GraphQLFieldInterface[] |
|
139 | + * @since $VID:$ |
|
140 | + */ |
|
141 | + public function fields(): array |
|
142 | + { |
|
143 | + return (array) $this->fields; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @param GraphQLFieldInterface[] $fields |
|
149 | + */ |
|
150 | + protected function setFields(array $fields) |
|
151 | + { |
|
152 | + foreach ($fields as $field) { |
|
153 | + if ($field instanceof GraphQLField) { |
|
154 | + $this->fields[] = $field; |
|
155 | + } |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * Creates a key map for internal resolver. |
|
162 | + * |
|
163 | + * @return array |
|
164 | + * @since $VID:$ |
|
165 | + */ |
|
166 | + public function getFieldsForResolver(): array |
|
167 | + { |
|
168 | + $fields = []; |
|
169 | + foreach ($this->fields() as $field) { |
|
170 | + if ($field->useForOutput()) { |
|
171 | + $fields[ $field->name() ] = $field; |
|
172 | + } |
|
173 | + } |
|
174 | + return $fields; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @return bool |
|
180 | + */ |
|
181 | + public function isCustomPostType(): bool |
|
182 | + { |
|
183 | + return $this->is_custom_post_type; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * @param bool $is_custom_post_type |
|
189 | + */ |
|
190 | + protected function setIsCustomPostType(bool $is_custom_post_type) |
|
191 | + { |
|
192 | + $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * @param int|float $value |
|
198 | + * @return int |
|
199 | + * @since $VID:$ |
|
200 | + */ |
|
201 | + public function parseInfiniteValue($value): int |
|
202 | + { |
|
203 | + $value = trim($value); |
|
204 | + return $value === null |
|
205 | + || $value === '' |
|
206 | + || $value === '∞' |
|
207 | + || $value === 'INF' |
|
208 | + || $value === INF |
|
209 | + || $value === EE_INF |
|
210 | + || is_infinite((float) $value) |
|
211 | + ? -1 |
|
212 | + : $value; |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * @param mixed $source |
|
218 | + * @return EE_Base_Class|null |
|
219 | + * @throws EE_Error |
|
220 | + */ |
|
221 | + private function getModel($source): ?EE_Base_Class |
|
222 | + { |
|
223 | + // If it comes from a custom connection |
|
224 | + // where the $source is already instantiated. |
|
225 | + if ($source instanceof EE_Base_Class) { |
|
226 | + return $source; |
|
227 | + } |
|
228 | + return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
234 | + * @param array $args The inputArgs on the field |
|
235 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
236 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
237 | + * @return EE_Base_Class|Deferred|string|null |
|
238 | + * @throws EE_Error |
|
239 | + * @throws InvalidDataTypeException |
|
240 | + * @throws InvalidInterfaceException |
|
241 | + * @throws UnexpectedEntityException |
|
242 | + * @throws UserError |
|
243 | + * @throws InvalidArgumentException |
|
244 | + * @throws ReflectionException |
|
245 | + * @since $VID:$ |
|
246 | + */ |
|
247 | + public function resolveField($source, array $args, AppContext $context, ResolveInfo $info) |
|
248 | + { |
|
249 | + $source = $source instanceof RootQuery ? $source : $this->getModel($source); |
|
250 | + |
|
251 | + return $this->field_resolver->resolve($source, $args, $context, $info); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @param mixed $payload The payload returned after mutation |
|
257 | + * @param array $args The inputArgs on the field |
|
258 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
259 | + * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null |
|
260 | + * @throws EE_Error |
|
261 | + */ |
|
262 | + public function resolveFromPayload($payload, array $args, AppContext $context) |
|
263 | + { |
|
264 | + if (empty($payload['id'])) { |
|
265 | + return null; |
|
266 | + } |
|
267 | + return $this->model->get_one_by_ID($payload['id']); |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * Prepares a datetime value in ISO8601/RFC3339 format. |
|
273 | + * It is assumed that the value of $datetime is in the format |
|
274 | + * returned by EE_Base_Class::get_format(). |
|
275 | + * |
|
276 | + * @param string $datetime The datetime value. |
|
277 | + * @param EE_Base_Class $source The source object. |
|
278 | + * @return string ISO8601/RFC3339 formatted datetime. |
|
279 | + */ |
|
280 | + public function formatDatetime(string $datetime, EE_Base_Class $source): string |
|
281 | + { |
|
282 | + $format = $source->get_format(); |
|
283 | + // create date object based on local timezone |
|
284 | + $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone())); |
|
285 | + // change the timezone to UTC |
|
286 | + $datetime->setTimezone(new DateTimeZone('UTC')); |
|
287 | + |
|
288 | + return $datetime->format(DateTime::RFC3339); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * Converts an object to JSON. The object must have a "toJson" method. |
|
294 | + * |
|
295 | + * @param string $object The object/value. |
|
296 | + * @param EE_Base_Class $source The source object. |
|
297 | + * @return string JSON representation of the object. |
|
298 | + */ |
|
299 | + public function toJson(JsonableInterface $object, EE_Base_Class $source): string |
|
300 | + { |
|
301 | + return $object->toJson(); |
|
302 | + } |
|
303 | 303 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class ResolverCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * ResolverCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
39 | - ResolverCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * ResolverCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
39 | + ResolverCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - ResolverCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\resolvers'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + ResolverCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\resolvers'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since $VID:$ |
|
82 | - */ |
|
83 | - public function loadResolvers() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since $VID:$ |
|
82 | + */ |
|
83 | + public function loadResolvers() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class EnumCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_enums'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_enums'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * EnumCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
39 | - EnumCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * EnumCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
39 | + EnumCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - EnumCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\enums'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + EnumCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\enums'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since $VID:$ |
|
82 | - */ |
|
83 | - public function loadEnums() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since $VID:$ |
|
82 | + */ |
|
83 | + public function loadEnums() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class InputCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_inputs'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_inputs'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * InputCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
39 | - InputCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * InputCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
39 | + InputCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - InputCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_InputCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\inputs'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + InputCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_InputCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\inputs'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since $VID:$ |
|
82 | - */ |
|
83 | - public function loadInputs() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since $VID:$ |
|
82 | + */ |
|
83 | + public function loadInputs() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -20,89 +20,89 @@ |
||
20 | 20 | */ |
21 | 21 | class TypeCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_types'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_types'; |
|
24 | 24 | |
25 | - const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface'; |
|
25 | + const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var CollectionLoader $loader |
|
29 | - */ |
|
30 | - protected $loader; |
|
27 | + /** |
|
28 | + * @var CollectionLoader $loader |
|
29 | + */ |
|
30 | + protected $loader; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * TypeCollection constructor |
|
35 | - * |
|
36 | - * @throws InvalidInterfaceException |
|
37 | - */ |
|
38 | - public function __construct() |
|
39 | - { |
|
40 | - parent::__construct( |
|
41 | - TypeCollection::COLLECTION_INTERFACE, |
|
42 | - TypeCollection::COLLECTION_NAME |
|
43 | - ); |
|
44 | - } |
|
33 | + /** |
|
34 | + * TypeCollection constructor |
|
35 | + * |
|
36 | + * @throws InvalidInterfaceException |
|
37 | + */ |
|
38 | + public function __construct() |
|
39 | + { |
|
40 | + parent::__construct( |
|
41 | + TypeCollection::COLLECTION_INTERFACE, |
|
42 | + TypeCollection::COLLECTION_NAME |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @throws CollectionDetailsException |
|
49 | - * @throws CollectionLoaderException |
|
50 | - * @since $VID:$ |
|
51 | - */ |
|
52 | - private function loadCollection() |
|
53 | - { |
|
54 | - if (! $this->loader instanceof CollectionLoader) { |
|
55 | - $this->loader = new CollectionLoader( |
|
56 | - new CollectionDetails( |
|
57 | - // collection name |
|
58 | - TypeCollection::COLLECTION_NAME, |
|
59 | - // collection interface |
|
60 | - TypeCollection::COLLECTION_INTERFACE, |
|
61 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
62 | - apply_filters( |
|
63 | - 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
64 | - ['EventEspresso\core\domain\services\graphql\types'] |
|
65 | - ), |
|
66 | - // filepaths to classes to add |
|
67 | - array(), |
|
68 | - // file mask to use if parsing folder for files to add |
|
69 | - '', |
|
70 | - // what to use as identifier for collection entities |
|
71 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
72 | - CollectionDetails::ID_CLASS_NAME |
|
73 | - ), |
|
74 | - $this |
|
75 | - ); |
|
76 | - } |
|
77 | - } |
|
47 | + /** |
|
48 | + * @throws CollectionDetailsException |
|
49 | + * @throws CollectionLoaderException |
|
50 | + * @since $VID:$ |
|
51 | + */ |
|
52 | + private function loadCollection() |
|
53 | + { |
|
54 | + if (! $this->loader instanceof CollectionLoader) { |
|
55 | + $this->loader = new CollectionLoader( |
|
56 | + new CollectionDetails( |
|
57 | + // collection name |
|
58 | + TypeCollection::COLLECTION_NAME, |
|
59 | + // collection interface |
|
60 | + TypeCollection::COLLECTION_INTERFACE, |
|
61 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
62 | + apply_filters( |
|
63 | + 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
64 | + ['EventEspresso\core\domain\services\graphql\types'] |
|
65 | + ), |
|
66 | + // filepaths to classes to add |
|
67 | + array(), |
|
68 | + // file mask to use if parsing folder for files to add |
|
69 | + '', |
|
70 | + // what to use as identifier for collection entities |
|
71 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
72 | + CollectionDetails::ID_CLASS_NAME |
|
73 | + ), |
|
74 | + $this |
|
75 | + ); |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @return CollectionInterface |
|
82 | - * @throws CollectionDetailsException |
|
83 | - * @throws CollectionLoaderException |
|
84 | - * @since $VID:$ |
|
85 | - */ |
|
86 | - public function loadTypes() |
|
87 | - { |
|
88 | - $this->loadCollection(); |
|
89 | - return $this->loader->getCollection(); |
|
90 | - } |
|
80 | + /** |
|
81 | + * @return CollectionInterface |
|
82 | + * @throws CollectionDetailsException |
|
83 | + * @throws CollectionLoaderException |
|
84 | + * @since $VID:$ |
|
85 | + */ |
|
86 | + public function loadTypes() |
|
87 | + { |
|
88 | + $this->loadCollection(); |
|
89 | + return $this->loader->getCollection(); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * getIdentifier |
|
95 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
96 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
97 | - * |
|
98 | - * @param $object |
|
99 | - * @param mixed $identifier |
|
100 | - * @return bool |
|
101 | - */ |
|
102 | - public function getIdentifier($object, $identifier = null) |
|
103 | - { |
|
104 | - return ! empty($identifier) |
|
105 | - ? $identifier |
|
106 | - : get_class($object); |
|
107 | - } |
|
93 | + /** |
|
94 | + * getIdentifier |
|
95 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
96 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
97 | + * |
|
98 | + * @param $object |
|
99 | + * @param mixed $identifier |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + public function getIdentifier($object, $identifier = null) |
|
103 | + { |
|
104 | + return ! empty($identifier) |
|
105 | + ? $identifier |
|
106 | + : get_class($object); |
|
107 | + } |
|
108 | 108 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | $inputFields = []; |
69 | 69 | foreach ($input->fields() as $field) { |
70 | 70 | $fieldName = $field->name(); |
71 | - $inputFields[ $fieldName ] = $field->toArray(); |
|
71 | + $inputFields[$fieldName] = $field->toArray(); |
|
72 | 72 | } |
73 | 73 | // Register the input type. |
74 | 74 | register_graphql_input_type( |
@@ -17,65 +17,65 @@ |
||
17 | 17 | */ |
18 | 18 | class InputsManager implements GQLManagerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var InputCollection|InputInterface[] $inputs |
|
22 | - */ |
|
23 | - private $inputs; |
|
20 | + /** |
|
21 | + * @var InputCollection|InputInterface[] $inputs |
|
22 | + */ |
|
23 | + private $inputs; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * InputsManager constructor. |
|
28 | - * |
|
29 | - * @param InputCollection|InputInterface[] $inputs |
|
30 | - */ |
|
31 | - public function __construct(InputCollection $inputs) |
|
32 | - { |
|
33 | - $this->inputs = $inputs; |
|
34 | - } |
|
26 | + /** |
|
27 | + * InputsManager constructor. |
|
28 | + * |
|
29 | + * @param InputCollection|InputInterface[] $inputs |
|
30 | + */ |
|
31 | + public function __construct(InputCollection $inputs) |
|
32 | + { |
|
33 | + $this->inputs = $inputs; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @throws CollectionDetailsException |
|
39 | - * @throws CollectionLoaderException |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function init() |
|
43 | - { |
|
44 | - $this->inputs->loadInputs(); |
|
45 | - add_action('graphql_register_types', [$this, 'configureInputs'], 9); |
|
46 | - } |
|
37 | + /** |
|
38 | + * @throws CollectionDetailsException |
|
39 | + * @throws CollectionLoaderException |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function init() |
|
43 | + { |
|
44 | + $this->inputs->loadInputs(); |
|
45 | + add_action('graphql_register_types', [$this, 'configureInputs'], 9); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @since $VID:$ |
|
51 | - */ |
|
52 | - public function configureInputs() |
|
53 | - { |
|
54 | - // loop through the collection of inputs and register their fields |
|
55 | - foreach ($this->inputs as $input) { |
|
56 | - $this->registerInput($input); |
|
57 | - } |
|
58 | - } |
|
49 | + /** |
|
50 | + * @since $VID:$ |
|
51 | + */ |
|
52 | + public function configureInputs() |
|
53 | + { |
|
54 | + // loop through the collection of inputs and register their fields |
|
55 | + foreach ($this->inputs as $input) { |
|
56 | + $this->registerInput($input); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @param InputInterface $input |
|
63 | - * @since $VID:$ |
|
64 | - */ |
|
65 | - public function registerInput(InputInterface $input) |
|
66 | - { |
|
67 | - $inputFields = []; |
|
68 | - foreach ($input->fields() as $field) { |
|
69 | - $fieldName = $field->name(); |
|
70 | - $inputFields[ $fieldName ] = $field->toArray(); |
|
71 | - } |
|
72 | - // Register the input type. |
|
73 | - register_graphql_input_type( |
|
74 | - $input->name(), |
|
75 | - [ |
|
76 | - 'description' => $input->description(), |
|
77 | - 'fields' => $inputFields, |
|
78 | - ] |
|
79 | - ); |
|
80 | - } |
|
61 | + /** |
|
62 | + * @param InputInterface $input |
|
63 | + * @since $VID:$ |
|
64 | + */ |
|
65 | + public function registerInput(InputInterface $input) |
|
66 | + { |
|
67 | + $inputFields = []; |
|
68 | + foreach ($input->fields() as $field) { |
|
69 | + $fieldName = $field->name(); |
|
70 | + $inputFields[ $fieldName ] = $field->toArray(); |
|
71 | + } |
|
72 | + // Register the input type. |
|
73 | + register_graphql_input_type( |
|
74 | + $input->name(), |
|
75 | + [ |
|
76 | + 'description' => $input->description(), |
|
77 | + 'fields' => $inputFields, |
|
78 | + ] |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class ConnectionCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * ConnectionCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
39 | - ConnectionCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * ConnectionCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
39 | + ConnectionCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - ConnectionCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\connections'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + ConnectionCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\connections'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since $VID:$ |
|
82 | - */ |
|
83 | - public function loadConnections() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since $VID:$ |
|
82 | + */ |
|
83 | + public function loadConnections() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | // unfortunately, this needs to be done upon INCLUSION of this file, |
13 | 13 | // instead of construction, because it only gets constructed on first page load |
14 | 14 | // (all other times it gets resurrected from a wordpress option) |
15 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
|
15 | +$stages = glob(EE_CORE.'data_migration_scripts/4_10_0_stages/*'); |
|
16 | 16 | $class_to_filepath = []; |
17 | 17 | foreach ($stages as $filepath) { |
18 | 18 | $matches = []; |
19 | 19 | preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
20 | + $class_to_filepath[$matches[1]] = $filepath; |
|
21 | 21 | } |
22 | 22 | // give addons a chance to autoload their stages too |
23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | $version_string = $version_array['Core']; |
68 | 68 | if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
69 | 69 | return true; |
70 | - } elseif (! $version_string) { |
|
70 | + } elseif ( ! $version_string) { |
|
71 | 71 | // echo "no version string provided: $version_string"; |
72 | 72 | // no version string provided... this must be pre 4.3 |
73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
73 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
74 | 74 | } |
75 | 75 | return false; |
76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function schema_changes_before_migration() |
84 | 84 | { |
85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
86 | 86 | $now_in_mysql = current_time('mysql', true); |
87 | 87 | $table_name = 'esp_answer'; |
88 | 88 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | { |
634 | 634 | global $wpdb; |
635 | 635 | $wpdb->update( |
636 | - $wpdb->prefix . 'esp_payment_method', |
|
636 | + $wpdb->prefix.'esp_payment_method', |
|
637 | 637 | [ |
638 | 638 | 'PMD_type' => 'Admin_Only', |
639 | 639 | 'PMD_scope' => serialize(array()) |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
16 | 16 | $class_to_filepath = []; |
17 | 17 | foreach ($stages as $filepath) { |
18 | - $matches = []; |
|
19 | - preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | + $matches = []; |
|
19 | + preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
21 | 21 | } |
22 | 22 | // give addons a chance to autoload their stages too |
23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -35,66 +35,66 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base |
37 | 37 | { |
38 | - /** |
|
39 | - * |
|
40 | - * @param TableManager $table_manager |
|
41 | - * @param TableAnalysis $table_analysis |
|
42 | - */ |
|
43 | - public function __construct( |
|
44 | - TableManager $table_manager = null, |
|
45 | - TableAnalysis $table_analysis = null, |
|
46 | - EE_DMS_Core_4_9_0 $dms_4_9 |
|
47 | - ) { |
|
48 | - $this->previous_dms = $dms_4_9; |
|
49 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
50 | - $this->_priority = 10; |
|
51 | - $this->_migration_stages = array( |
|
52 | - new EE_DMS_4_10_0_Event_Question_Group(), |
|
53 | - ); |
|
54 | - parent::__construct($table_manager, $table_analysis); |
|
55 | - } |
|
38 | + /** |
|
39 | + * |
|
40 | + * @param TableManager $table_manager |
|
41 | + * @param TableAnalysis $table_analysis |
|
42 | + */ |
|
43 | + public function __construct( |
|
44 | + TableManager $table_manager = null, |
|
45 | + TableAnalysis $table_analysis = null, |
|
46 | + EE_DMS_Core_4_9_0 $dms_4_9 |
|
47 | + ) { |
|
48 | + $this->previous_dms = $dms_4_9; |
|
49 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
50 | + $this->_priority = 10; |
|
51 | + $this->_migration_stages = array( |
|
52 | + new EE_DMS_4_10_0_Event_Question_Group(), |
|
53 | + ); |
|
54 | + parent::__construct($table_manager, $table_analysis); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Whether to migrate or not. |
|
61 | - * |
|
62 | - * @param array $version_array |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function can_migrate_from_version($version_array) |
|
66 | - { |
|
67 | - $version_string = $version_array['Core']; |
|
68 | - if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
69 | - return true; |
|
70 | - } elseif (! $version_string) { |
|
71 | - // echo "no version string provided: $version_string"; |
|
72 | - // no version string provided... this must be pre 4.3 |
|
73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
74 | - } |
|
75 | - return false; |
|
76 | - } |
|
59 | + /** |
|
60 | + * Whether to migrate or not. |
|
61 | + * |
|
62 | + * @param array $version_array |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function can_migrate_from_version($version_array) |
|
66 | + { |
|
67 | + $version_string = $version_array['Core']; |
|
68 | + if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
69 | + return true; |
|
70 | + } elseif (! $version_string) { |
|
71 | + // echo "no version string provided: $version_string"; |
|
72 | + // no version string provided... this must be pre 4.3 |
|
73 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
74 | + } |
|
75 | + return false; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function schema_changes_before_migration() |
|
84 | - { |
|
85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
86 | - $now_in_mysql = current_time('mysql', true); |
|
87 | - $table_name = 'esp_answer'; |
|
88 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
80 | + /** |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function schema_changes_before_migration() |
|
84 | + { |
|
85 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
86 | + $now_in_mysql = current_time('mysql', true); |
|
87 | + $table_name = 'esp_answer'; |
|
88 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
89 | 89 | REG_ID int(10) unsigned NOT NULL, |
90 | 90 | QST_ID int(10) unsigned NOT NULL, |
91 | 91 | ANS_value text NOT NULL, |
92 | 92 | PRIMARY KEY (ANS_ID), |
93 | 93 | KEY REG_ID (REG_ID), |
94 | 94 | KEY QST_ID (QST_ID)"; |
95 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
96 | - $table_name = 'esp_attendee_meta'; |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
95 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
96 | + $table_name = 'esp_attendee_meta'; |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - // note: although this table is no longer in use, |
|
153 | - // it hasn't been removed because then queries to the model will have errors. |
|
154 | - // but you should expect this table and its corresponding model to be removed in |
|
155 | - // the next few months |
|
156 | - $table_name = 'esp_currency_payment_method'; |
|
157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + // note: although this table is no longer in use, |
|
153 | + // it hasn't been removed because then queries to the model will have errors. |
|
154 | + // but you should expect this table and its corresponding model to be removed in |
|
155 | + // the next few months |
|
156 | + $table_name = 'esp_currency_payment_method'; |
|
157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
158 | 158 | CUR_code varchar(6) NOT NULL, |
159 | 159 | PMD_ID int(11) NOT NULL, |
160 | 160 | PRIMARY KEY (CPM_ID), |
161 | 161 | KEY PMD_ID (PMD_ID)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | - $table_name = 'esp_datetime'; |
|
164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | + $table_name = 'esp_datetime'; |
|
164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
179 | 179 | KEY EVT_ID (EVT_ID), |
180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
181 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | - $table_name = "esp_datetime_ticket"; |
|
183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | + $table_name = "esp_datetime_ticket"; |
|
183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
186 | 186 | PRIMARY KEY (DTK_ID), |
187 | 187 | KEY DTT_ID (DTT_ID), |
188 | 188 | KEY TKT_ID (TKT_ID)"; |
189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | - $table_name = 'esp_event_message_template'; |
|
191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | + $table_name = 'esp_event_message_template'; |
|
191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EMT_ID), |
195 | 195 | KEY EVT_ID (EVT_ID), |
196 | 196 | KEY GRP_ID (GRP_ID)"; |
197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_meta'; |
|
199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_meta'; |
|
199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | EVT_donations tinyint(1) NULL, |
212 | 212 | PRIMARY KEY (EVTM_ID), |
213 | 213 | KEY EVT_ID (EVT_ID)"; |
214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | - $table_name = 'esp_event_question_group'; |
|
216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $table_name = 'esp_event_question_group'; |
|
216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -221,25 +221,25 @@ discard block |
||
221 | 221 | PRIMARY KEY (EQG_ID), |
222 | 222 | KEY EVT_ID (EVT_ID), |
223 | 223 | KEY QSG_ID (QSG_ID)"; |
224 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
225 | - $table_name = 'esp_event_venue'; |
|
226 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
224 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
225 | + $table_name = 'esp_event_venue'; |
|
226 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
227 | 227 | EVT_ID bigint(20) unsigned NOT NULL, |
228 | 228 | VNU_ID bigint(20) unsigned NOT NULL, |
229 | 229 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
230 | 230 | PRIMARY KEY (EVV_ID)"; |
231 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
232 | - $table_name = 'esp_extra_meta'; |
|
233 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
231 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
232 | + $table_name = 'esp_extra_meta'; |
|
233 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
234 | 234 | OBJ_ID int(11) DEFAULT NULL, |
235 | 235 | EXM_type varchar(45) DEFAULT NULL, |
236 | 236 | EXM_key varchar(45) DEFAULT NULL, |
237 | 237 | EXM_value text, |
238 | 238 | PRIMARY KEY (EXM_ID), |
239 | 239 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
240 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
241 | - $table_name = 'esp_extra_join'; |
|
242 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
240 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
241 | + $table_name = 'esp_extra_join'; |
|
242 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
243 | 243 | EXJ_first_model_id varchar(6) NOT NULL, |
244 | 244 | EXJ_first_model_name varchar(20) NOT NULL, |
245 | 245 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | PRIMARY KEY (EXJ_ID), |
248 | 248 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
249 | 249 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
250 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
251 | - $table_name = 'esp_line_item'; |
|
252 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
250 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
251 | + $table_name = 'esp_line_item'; |
|
252 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
253 | 253 | LIN_code varchar(245) NOT NULL DEFAULT '', |
254 | 254 | TXN_ID int(11) DEFAULT NULL, |
255 | 255 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
271 | 271 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
272 | 272 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
273 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
274 | - $table_name = 'esp_log'; |
|
275 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
273 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
274 | + $table_name = 'esp_log'; |
|
275 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
276 | 276 | LOG_time datetime DEFAULT NULL, |
277 | 277 | OBJ_ID varchar(45) DEFAULT NULL, |
278 | 278 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | KEY LOG_time (LOG_time), |
284 | 284 | KEY OBJ (OBJ_type,OBJ_ID), |
285 | 285 | KEY LOG_type (LOG_type)"; |
286 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
287 | - $table_name = 'esp_message'; |
|
288 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
286 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
287 | + $table_name = 'esp_message'; |
|
288 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | 289 | GRP_ID int(10) unsigned NULL, |
290 | 290 | MSG_token varchar(255) NULL, |
291 | 291 | TXN_ID int(10) unsigned NULL, |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | KEY STS_ID (STS_ID), |
318 | 318 | KEY MSG_created (MSG_created), |
319 | 319 | KEY MSG_modified (MSG_modified)"; |
320 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_message_template'; |
|
322 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_message_template'; |
|
322 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | 323 | GRP_ID int(10) unsigned NOT NULL, |
324 | 324 | MTP_context varchar(50) NOT NULL, |
325 | 325 | MTP_template_field varchar(30) NOT NULL, |
326 | 326 | MTP_content text NOT NULL, |
327 | 327 | PRIMARY KEY (MTP_ID), |
328 | 328 | KEY GRP_ID (GRP_ID)"; |
329 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | - $table_name = 'esp_message_template_group'; |
|
331 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
329 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | + $table_name = 'esp_message_template_group'; |
|
331 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | 332 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
333 | 333 | MTP_name varchar(245) NOT NULL DEFAULT '', |
334 | 334 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
341 | 341 | PRIMARY KEY (GRP_ID), |
342 | 342 | KEY MTP_user_id (MTP_user_id)"; |
343 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | - $table_name = 'esp_payment'; |
|
345 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | + $table_name = 'esp_payment'; |
|
345 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | TXN_ID int(10) unsigned DEFAULT NULL, |
347 | 347 | STS_ID varchar(3) DEFAULT NULL, |
348 | 348 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | PRIMARY KEY (PAY_ID), |
360 | 360 | KEY PAY_timestamp (PAY_timestamp), |
361 | 361 | KEY TXN_ID (TXN_ID)"; |
362 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | - $table_name = 'esp_payment_method'; |
|
364 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
362 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | + $table_name = 'esp_payment_method'; |
|
364 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
365 | 365 | PMD_type varchar(124) DEFAULT NULL, |
366 | 366 | PMD_name varchar(255) DEFAULT NULL, |
367 | 367 | PMD_desc text, |
@@ -377,24 +377,24 @@ discard block |
||
377 | 377 | PRIMARY KEY (PMD_ID), |
378 | 378 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
379 | 379 | KEY PMD_type (PMD_type)"; |
380 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | - $table_name = "esp_ticket_price"; |
|
382 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
380 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | + $table_name = "esp_ticket_price"; |
|
382 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | 383 | TKT_ID int(10) unsigned NOT NULL, |
384 | 384 | PRC_ID int(10) unsigned NOT NULL, |
385 | 385 | PRIMARY KEY (TKP_ID), |
386 | 386 | KEY TKT_ID (TKT_ID), |
387 | 387 | KEY PRC_ID (PRC_ID)"; |
388 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | - $table_name = "esp_ticket_template"; |
|
390 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
388 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | + $table_name = "esp_ticket_template"; |
|
390 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | 391 | TTM_name varchar(45) NOT NULL, |
392 | 392 | TTM_description text, |
393 | 393 | TTM_file varchar(45), |
394 | 394 | PRIMARY KEY (TTM_ID)"; |
395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | - $table_name = 'esp_question'; |
|
397 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | + $table_name = 'esp_question'; |
|
397 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
398 | 398 | QST_display_text text NOT NULL, |
399 | 399 | QST_admin_label varchar(255) NOT NULL, |
400 | 400 | QST_system varchar(25) DEFAULT NULL, |
@@ -408,18 +408,18 @@ discard block |
||
408 | 408 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
409 | 409 | PRIMARY KEY (QST_ID), |
410 | 410 | KEY QST_order (QST_order)'; |
411 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | - $table_name = 'esp_question_group_question'; |
|
413 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | + $table_name = 'esp_question_group_question'; |
|
413 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | 414 | QSG_ID int(10) unsigned NOT NULL, |
415 | 415 | QST_ID int(10) unsigned NOT NULL, |
416 | 416 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
417 | 417 | PRIMARY KEY (QGQ_ID), |
418 | 418 | KEY QST_ID (QST_ID), |
419 | 419 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | - $table_name = 'esp_question_option'; |
|
422 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | + $table_name = 'esp_question_option'; |
|
422 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
423 | 423 | QSO_value varchar(255) NOT NULL, |
424 | 424 | QSO_desc text NOT NULL, |
425 | 425 | QST_ID int(10) unsigned NOT NULL, |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | PRIMARY KEY (QSO_ID), |
430 | 430 | KEY QST_ID (QST_ID), |
431 | 431 | KEY QSO_order (QSO_order)"; |
432 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $table_name = 'esp_registration'; |
|
434 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_registration'; |
|
434 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | 435 | EVT_ID bigint(20) unsigned NOT NULL, |
436 | 436 | ATT_ID bigint(20) unsigned NOT NULL, |
437 | 437 | TXN_ID int(10) unsigned NOT NULL, |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | KEY TKT_ID (TKT_ID), |
456 | 456 | KEY EVT_ID (EVT_ID), |
457 | 457 | KEY STS_ID (STS_ID)"; |
458 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | - $table_name = 'esp_registration_payment'; |
|
460 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
458 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | + $table_name = 'esp_registration_payment'; |
|
460 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
461 | 461 | REG_ID int(10) unsigned NOT NULL, |
462 | 462 | PAY_ID int(10) unsigned NULL, |
463 | 463 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
464 | 464 | PRIMARY KEY (RPY_ID), |
465 | 465 | KEY REG_ID (REG_ID), |
466 | 466 | KEY PAY_ID (PAY_ID)"; |
467 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | - $table_name = 'esp_state'; |
|
469 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
467 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | + $table_name = 'esp_state'; |
|
469 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
470 | 470 | CNT_ISO varchar(2) NOT NULL, |
471 | 471 | STA_abbrev varchar(24) NOT NULL, |
472 | 472 | STA_name varchar(100) NOT NULL, |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | PRIMARY KEY (STA_ID), |
475 | 475 | KEY STA_abbrev (STA_abbrev), |
476 | 476 | KEY CNT_ISO (CNT_ISO)"; |
477 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | - $table_name = 'esp_status'; |
|
479 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
477 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | + $table_name = 'esp_status'; |
|
479 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
480 | 480 | STS_code varchar(45) NOT NULL, |
481 | 481 | STS_type varchar(45) NOT NULL, |
482 | 482 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
485 | 485 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
486 | 486 | KEY STS_type (STS_type)"; |
487 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - $table_name = 'esp_transaction'; |
|
489 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + $table_name = 'esp_transaction'; |
|
489 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
490 | 490 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
491 | 491 | TXN_total decimal(12,3) DEFAULT '0.00', |
492 | 492 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | PRIMARY KEY (TXN_ID), |
499 | 499 | KEY TXN_timestamp (TXN_timestamp), |
500 | 500 | KEY STS_ID (STS_ID)"; |
501 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | - $table_name = 'esp_venue_meta'; |
|
503 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
501 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | + $table_name = 'esp_venue_meta'; |
|
503 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
504 | 504 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
505 | 505 | VNU_address varchar(255) DEFAULT NULL, |
506 | 506 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | KEY VNU_ID (VNU_ID), |
520 | 520 | KEY STA_ID (STA_ID), |
521 | 521 | KEY CNT_ISO (CNT_ISO)"; |
522 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | - // modified tables |
|
524 | - $table_name = "esp_price"; |
|
525 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | + // modified tables |
|
524 | + $table_name = "esp_price"; |
|
525 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
526 | 526 | PRT_ID tinyint(3) unsigned NOT NULL, |
527 | 527 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
528 | 528 | PRC_name varchar(245) NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | PRC_parent int(10) unsigned DEFAULT 0, |
536 | 536 | PRIMARY KEY (PRC_ID), |
537 | 537 | KEY PRT_ID (PRT_ID)"; |
538 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | - $table_name = "esp_price_type"; |
|
540 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = "esp_price_type"; |
|
540 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | PRT_name varchar(45) NOT NULL, |
542 | 542 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
543 | 543 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
547 | 547 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
548 | 548 | PRIMARY KEY (PRT_ID)"; |
549 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | - $table_name = "esp_ticket"; |
|
551 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
549 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | + $table_name = "esp_ticket"; |
|
551 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
552 | 552 | TTM_ID int(10) unsigned NOT NULL, |
553 | 553 | TKT_name varchar(245) NOT NULL DEFAULT '', |
554 | 554 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
572 | 572 | PRIMARY KEY (TKT_ID), |
573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
574 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | - $table_name = 'esp_question_group'; |
|
576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
574 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | + $table_name = 'esp_question_group'; |
|
576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
577 | 577 | QSG_name varchar(255) NOT NULL, |
578 | 578 | QSG_identifier varchar(100) NOT NULL, |
579 | 579 | QSG_desc text NULL, |
@@ -586,70 +586,70 @@ discard block |
||
586 | 586 | PRIMARY KEY (QSG_ID), |
587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
588 | 588 | KEY QSG_order (QSG_order)'; |
589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | - $this->insert_default_data(); |
|
591 | - return true; |
|
592 | - } |
|
589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | + $this->insert_default_data(); |
|
591 | + return true; |
|
592 | + } |
|
593 | 593 | |
594 | - /** |
|
595 | - * Inserts default data on new installs |
|
596 | - * @since 4.10.0.p |
|
597 | - * @throws EE_Error |
|
598 | - * @throws InvalidArgumentException |
|
599 | - * @throws ReflectionException |
|
600 | - * @throws InvalidDataTypeException |
|
601 | - * @throws InvalidInterfaceException |
|
602 | - */ |
|
603 | - public function insert_default_data() |
|
604 | - { |
|
605 | - $this->previous_dms->insert_default_data(); |
|
606 | - $this->removeMijirehPM(); |
|
607 | - } |
|
594 | + /** |
|
595 | + * Inserts default data on new installs |
|
596 | + * @since 4.10.0.p |
|
597 | + * @throws EE_Error |
|
598 | + * @throws InvalidArgumentException |
|
599 | + * @throws ReflectionException |
|
600 | + * @throws InvalidDataTypeException |
|
601 | + * @throws InvalidInterfaceException |
|
602 | + */ |
|
603 | + public function insert_default_data() |
|
604 | + { |
|
605 | + $this->previous_dms->insert_default_data(); |
|
606 | + $this->removeMijirehPM(); |
|
607 | + } |
|
608 | 608 | |
609 | 609 | |
610 | 610 | |
611 | - /** |
|
612 | - * @return boolean |
|
613 | - */ |
|
614 | - public function schema_changes_after_migration() |
|
615 | - { |
|
616 | - return true; |
|
617 | - } |
|
611 | + /** |
|
612 | + * @return boolean |
|
613 | + */ |
|
614 | + public function schema_changes_after_migration() |
|
615 | + { |
|
616 | + return true; |
|
617 | + } |
|
618 | 618 | |
619 | 619 | |
620 | 620 | |
621 | - public function migration_page_hooks() |
|
622 | - { |
|
623 | - } |
|
621 | + public function migration_page_hooks() |
|
622 | + { |
|
623 | + } |
|
624 | 624 | |
625 | - /** |
|
626 | - * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't |
|
627 | - * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method |
|
628 | - * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on, |
|
629 | - * but it still exists so there's no problems. |
|
630 | - * @since 4.10.3.p |
|
631 | - */ |
|
632 | - protected function removeMijirehPM() |
|
633 | - { |
|
634 | - global $wpdb; |
|
635 | - $wpdb->update( |
|
636 | - $wpdb->prefix . 'esp_payment_method', |
|
637 | - [ |
|
638 | - 'PMD_type' => 'Admin_Only', |
|
639 | - 'PMD_scope' => serialize(array()) |
|
640 | - ], |
|
641 | - [ |
|
642 | - 'PMD_type' => 'Mijireh' |
|
643 | - ], |
|
644 | - [ |
|
645 | - // update formats |
|
646 | - '%s', // PMD_type |
|
647 | - '%s', // PMD_scope |
|
648 | - ], |
|
649 | - [ |
|
650 | - // where formats |
|
651 | - '%s' |
|
652 | - ] |
|
653 | - ); |
|
654 | - } |
|
625 | + /** |
|
626 | + * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't |
|
627 | + * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method |
|
628 | + * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on, |
|
629 | + * but it still exists so there's no problems. |
|
630 | + * @since 4.10.3.p |
|
631 | + */ |
|
632 | + protected function removeMijirehPM() |
|
633 | + { |
|
634 | + global $wpdb; |
|
635 | + $wpdb->update( |
|
636 | + $wpdb->prefix . 'esp_payment_method', |
|
637 | + [ |
|
638 | + 'PMD_type' => 'Admin_Only', |
|
639 | + 'PMD_scope' => serialize(array()) |
|
640 | + ], |
|
641 | + [ |
|
642 | + 'PMD_type' => 'Mijireh' |
|
643 | + ], |
|
644 | + [ |
|
645 | + // update formats |
|
646 | + '%s', // PMD_type |
|
647 | + '%s', // PMD_scope |
|
648 | + ], |
|
649 | + [ |
|
650 | + // where formats |
|
651 | + '%s' |
|
652 | + ] |
|
653 | + ); |
|
654 | + } |
|
655 | 655 | } |