@@ -17,143 +17,143 @@ |
||
17 | 17 | class VenueConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @return EEM_Venue |
|
22 | - * @throws EE_Error |
|
23 | - * @throws InvalidArgumentException |
|
24 | - * @throws InvalidDataTypeException |
|
25 | - * @throws InvalidInterfaceException |
|
26 | - */ |
|
27 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
28 | - public function get_query() |
|
29 | - { |
|
30 | - return EEM_Venue::instance(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Return an array of items from the query |
|
36 | - * |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
40 | - public function get_items() |
|
41 | - { |
|
42 | - |
|
43 | - $results = $this->query->get_col($this->query_args); |
|
44 | - |
|
45 | - return ! empty($results) ? $results : []; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Determine whether the Query should execute. If it's determined that the query should |
|
51 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
52 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
53 | - * Return false to prevent the query from executing. |
|
54 | - * |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
58 | - public function should_execute() |
|
59 | - { |
|
60 | - |
|
61 | - if (false === $this->should_execute) { |
|
62 | - return false; |
|
63 | - } |
|
64 | - |
|
65 | - return $this->should_execute; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
71 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
72 | - * handle batch resolution of the posts. |
|
73 | - * |
|
74 | - * @return array |
|
75 | - */ |
|
76 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
77 | - public function get_query_args() |
|
78 | - { |
|
79 | - |
|
80 | - $query_args = []; |
|
81 | - |
|
82 | - /** |
|
83 | - * Prepare for later use |
|
84 | - */ |
|
85 | - $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
86 | - $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
87 | - |
|
88 | - /** |
|
89 | - * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
90 | - */ |
|
91 | - $query_args['limit'] = min( |
|
92 | - max(absint($first), absint($last), 10), |
|
93 | - $this->query_amount |
|
94 | - ) + 1; |
|
95 | - |
|
96 | - /** |
|
97 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
98 | - */ |
|
99 | - $input_fields = []; |
|
100 | - if (! empty($this->args['where'])) { |
|
101 | - $input_fields = $this->sanitize_input_fields($this->args['where']); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
106 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
107 | - * set the query to pull datetimes that belong to that event. |
|
108 | - * We can set more cases for other source types. |
|
109 | - */ |
|
110 | - if (is_object($this->source)) { |
|
111 | - switch (true) { |
|
112 | - // Assumed to be an event |
|
113 | - case $this->source instanceof Post: |
|
114 | - $query_args[] = ['Event.EVT_ID' => $this->source->ID]; |
|
115 | - break; |
|
116 | - case $this->source instanceof EE_Event: |
|
117 | - $query_args[] = ['Event.EVT_ID' => $this->source->ID()]; |
|
118 | - break; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Merge the input_fields with the default query_args |
|
124 | - */ |
|
125 | - if (! empty($input_fields)) { |
|
126 | - $query_args = array_merge($query_args, $input_fields); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Return the $query_args |
|
131 | - */ |
|
132 | - return $query_args; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
|
138 | - * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
|
139 | - * this was quick. I'd be down to explore more dynamic ways to map this, but for |
|
140 | - * now this gets the job done. |
|
141 | - * |
|
142 | - * @param array $query_args |
|
143 | - * @return array |
|
144 | - */ |
|
145 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
146 | - public function sanitize_input_fields(array $query_args) |
|
147 | - { |
|
148 | - |
|
149 | - $arg_mapping = [ |
|
150 | - 'orderBy' => 'order_by', |
|
151 | - 'order' => 'order', |
|
152 | - ]; |
|
153 | - |
|
154 | - /** |
|
155 | - * Return the Query Args |
|
156 | - */ |
|
157 | - return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
158 | - } |
|
20 | + /** |
|
21 | + * @return EEM_Venue |
|
22 | + * @throws EE_Error |
|
23 | + * @throws InvalidArgumentException |
|
24 | + * @throws InvalidDataTypeException |
|
25 | + * @throws InvalidInterfaceException |
|
26 | + */ |
|
27 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
28 | + public function get_query() |
|
29 | + { |
|
30 | + return EEM_Venue::instance(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Return an array of items from the query |
|
36 | + * |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
40 | + public function get_items() |
|
41 | + { |
|
42 | + |
|
43 | + $results = $this->query->get_col($this->query_args); |
|
44 | + |
|
45 | + return ! empty($results) ? $results : []; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Determine whether the Query should execute. If it's determined that the query should |
|
51 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
52 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
53 | + * Return false to prevent the query from executing. |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
58 | + public function should_execute() |
|
59 | + { |
|
60 | + |
|
61 | + if (false === $this->should_execute) { |
|
62 | + return false; |
|
63 | + } |
|
64 | + |
|
65 | + return $this->should_execute; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
71 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
72 | + * handle batch resolution of the posts. |
|
73 | + * |
|
74 | + * @return array |
|
75 | + */ |
|
76 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
77 | + public function get_query_args() |
|
78 | + { |
|
79 | + |
|
80 | + $query_args = []; |
|
81 | + |
|
82 | + /** |
|
83 | + * Prepare for later use |
|
84 | + */ |
|
85 | + $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
86 | + $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
87 | + |
|
88 | + /** |
|
89 | + * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
90 | + */ |
|
91 | + $query_args['limit'] = min( |
|
92 | + max(absint($first), absint($last), 10), |
|
93 | + $this->query_amount |
|
94 | + ) + 1; |
|
95 | + |
|
96 | + /** |
|
97 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
98 | + */ |
|
99 | + $input_fields = []; |
|
100 | + if (! empty($this->args['where'])) { |
|
101 | + $input_fields = $this->sanitize_input_fields($this->args['where']); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
106 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
107 | + * set the query to pull datetimes that belong to that event. |
|
108 | + * We can set more cases for other source types. |
|
109 | + */ |
|
110 | + if (is_object($this->source)) { |
|
111 | + switch (true) { |
|
112 | + // Assumed to be an event |
|
113 | + case $this->source instanceof Post: |
|
114 | + $query_args[] = ['Event.EVT_ID' => $this->source->ID]; |
|
115 | + break; |
|
116 | + case $this->source instanceof EE_Event: |
|
117 | + $query_args[] = ['Event.EVT_ID' => $this->source->ID()]; |
|
118 | + break; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Merge the input_fields with the default query_args |
|
124 | + */ |
|
125 | + if (! empty($input_fields)) { |
|
126 | + $query_args = array_merge($query_args, $input_fields); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Return the $query_args |
|
131 | + */ |
|
132 | + return $query_args; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
|
138 | + * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
|
139 | + * this was quick. I'd be down to explore more dynamic ways to map this, but for |
|
140 | + * now this gets the job done. |
|
141 | + * |
|
142 | + * @param array $query_args |
|
143 | + * @return array |
|
144 | + */ |
|
145 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
146 | + public function sanitize_input_fields(array $query_args) |
|
147 | + { |
|
148 | + |
|
149 | + $arg_mapping = [ |
|
150 | + 'orderBy' => 'order_by', |
|
151 | + 'order' => 'order', |
|
152 | + ]; |
|
153 | + |
|
154 | + /** |
|
155 | + * Return the Query Args |
|
156 | + */ |
|
157 | + return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
158 | + } |
|
159 | 159 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
98 | 98 | */ |
99 | 99 | $input_fields = []; |
100 | - if (! empty($this->args['where'])) { |
|
100 | + if ( ! empty($this->args['where'])) { |
|
101 | 101 | $input_fields = $this->sanitize_input_fields($this->args['where']); |
102 | 102 | } |
103 | 103 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * Merge the input_fields with the default query_args |
124 | 124 | */ |
125 | - if (! empty($input_fields)) { |
|
125 | + if ( ! empty($input_fields)) { |
|
126 | 126 | $query_args = array_merge($query_args, $input_fields); |
127 | 127 | } |
128 | 128 |
@@ -19,149 +19,149 @@ |
||
19 | 19 | class DatetimeConnectionResolver extends AbstractConnectionResolver |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @return EEM_Datetime |
|
24 | - * @throws EE_Error |
|
25 | - * @throws InvalidArgumentException |
|
26 | - * @throws InvalidDataTypeException |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - */ |
|
29 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
30 | - public function get_query() |
|
31 | - { |
|
32 | - return EEM_Datetime::instance(); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Return an array of items from the query |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
42 | - public function get_items() |
|
43 | - { |
|
44 | - |
|
45 | - $results = $this->query->get_col($this->query_args); |
|
46 | - |
|
47 | - return ! empty($results) ? $results : []; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Determine whether the Query should execute. If it's determined that the query should |
|
53 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
54 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
55 | - * Return false to prevent the query from executing. |
|
56 | - * |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
60 | - public function should_execute() |
|
61 | - { |
|
62 | - |
|
63 | - if (false === $this->should_execute) { |
|
64 | - return false; |
|
65 | - } |
|
66 | - |
|
67 | - return $this->should_execute; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
73 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
74 | - * handle batch resolution of the posts. |
|
75 | - * |
|
76 | - * @return array |
|
77 | - */ |
|
78 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | - public function get_query_args() |
|
80 | - { |
|
81 | - |
|
82 | - $query_args = []; |
|
83 | - |
|
84 | - /** |
|
85 | - * Prepare for later use |
|
86 | - */ |
|
87 | - $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
88 | - $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
89 | - |
|
90 | - /** |
|
91 | - * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
92 | - */ |
|
93 | - $query_args['limit'] = min( |
|
94 | - max(absint($first), absint($last), 10), |
|
95 | - $this->query_amount |
|
96 | - ) + 1; |
|
97 | - |
|
98 | - /** |
|
99 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
100 | - */ |
|
101 | - $input_fields = []; |
|
102 | - if (! empty($this->args['where'])) { |
|
103 | - $input_fields = $this->sanitize_input_fields($this->args['where']); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
108 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
109 | - * set the query to pull datetimes that belong to that event. |
|
110 | - * We can set more cases for other source types. |
|
111 | - */ |
|
112 | - if (is_object($this->source)) { |
|
113 | - switch (true) { |
|
114 | - // It's surely an event |
|
115 | - case $this->source instanceof Post: |
|
116 | - $query_args[] = ['EVT_ID' => $this->source->ID]; |
|
117 | - break; |
|
118 | - case $this->source instanceof EE_Event: |
|
119 | - $query_args[] = ['EVT_ID' => $this->source->ID()]; |
|
120 | - break; |
|
121 | - case $this->source instanceof EE_Ticket: |
|
122 | - $query_args[] = ['Ticket.TKT_ID' => $this->source->ID()]; |
|
123 | - break; |
|
124 | - case $this->source instanceof EE_Checkin: |
|
125 | - $query_args[] = ['Checkin.CHK_ID' => $this->source->ID()]; |
|
126 | - break; |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Merge the input_fields with the default query_args |
|
132 | - */ |
|
133 | - if (! empty($input_fields)) { |
|
134 | - $query_args = array_merge($query_args, $input_fields); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Return the $query_args |
|
139 | - */ |
|
140 | - return $query_args; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
|
146 | - * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
|
147 | - * this was quick. I'd be down to explore more dynamic ways to map this, but for |
|
148 | - * now this gets the job done. |
|
149 | - * |
|
150 | - * @param array $query_args |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
154 | - public function sanitize_input_fields(array $query_args) |
|
155 | - { |
|
156 | - |
|
157 | - $arg_mapping = [ |
|
158 | - 'orderBy' => 'order_by', |
|
159 | - 'order' => 'order', |
|
160 | - ]; |
|
161 | - |
|
162 | - /** |
|
163 | - * Return the Query Args |
|
164 | - */ |
|
165 | - return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
166 | - } |
|
22 | + /** |
|
23 | + * @return EEM_Datetime |
|
24 | + * @throws EE_Error |
|
25 | + * @throws InvalidArgumentException |
|
26 | + * @throws InvalidDataTypeException |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + */ |
|
29 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
30 | + public function get_query() |
|
31 | + { |
|
32 | + return EEM_Datetime::instance(); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Return an array of items from the query |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
42 | + public function get_items() |
|
43 | + { |
|
44 | + |
|
45 | + $results = $this->query->get_col($this->query_args); |
|
46 | + |
|
47 | + return ! empty($results) ? $results : []; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Determine whether the Query should execute. If it's determined that the query should |
|
53 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
54 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
55 | + * Return false to prevent the query from executing. |
|
56 | + * |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
60 | + public function should_execute() |
|
61 | + { |
|
62 | + |
|
63 | + if (false === $this->should_execute) { |
|
64 | + return false; |
|
65 | + } |
|
66 | + |
|
67 | + return $this->should_execute; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
73 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
74 | + * handle batch resolution of the posts. |
|
75 | + * |
|
76 | + * @return array |
|
77 | + */ |
|
78 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | + public function get_query_args() |
|
80 | + { |
|
81 | + |
|
82 | + $query_args = []; |
|
83 | + |
|
84 | + /** |
|
85 | + * Prepare for later use |
|
86 | + */ |
|
87 | + $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
88 | + $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
89 | + |
|
90 | + /** |
|
91 | + * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
92 | + */ |
|
93 | + $query_args['limit'] = min( |
|
94 | + max(absint($first), absint($last), 10), |
|
95 | + $this->query_amount |
|
96 | + ) + 1; |
|
97 | + |
|
98 | + /** |
|
99 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
100 | + */ |
|
101 | + $input_fields = []; |
|
102 | + if (! empty($this->args['where'])) { |
|
103 | + $input_fields = $this->sanitize_input_fields($this->args['where']); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
108 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
109 | + * set the query to pull datetimes that belong to that event. |
|
110 | + * We can set more cases for other source types. |
|
111 | + */ |
|
112 | + if (is_object($this->source)) { |
|
113 | + switch (true) { |
|
114 | + // It's surely an event |
|
115 | + case $this->source instanceof Post: |
|
116 | + $query_args[] = ['EVT_ID' => $this->source->ID]; |
|
117 | + break; |
|
118 | + case $this->source instanceof EE_Event: |
|
119 | + $query_args[] = ['EVT_ID' => $this->source->ID()]; |
|
120 | + break; |
|
121 | + case $this->source instanceof EE_Ticket: |
|
122 | + $query_args[] = ['Ticket.TKT_ID' => $this->source->ID()]; |
|
123 | + break; |
|
124 | + case $this->source instanceof EE_Checkin: |
|
125 | + $query_args[] = ['Checkin.CHK_ID' => $this->source->ID()]; |
|
126 | + break; |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Merge the input_fields with the default query_args |
|
132 | + */ |
|
133 | + if (! empty($input_fields)) { |
|
134 | + $query_args = array_merge($query_args, $input_fields); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Return the $query_args |
|
139 | + */ |
|
140 | + return $query_args; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
|
146 | + * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
|
147 | + * this was quick. I'd be down to explore more dynamic ways to map this, but for |
|
148 | + * now this gets the job done. |
|
149 | + * |
|
150 | + * @param array $query_args |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
154 | + public function sanitize_input_fields(array $query_args) |
|
155 | + { |
|
156 | + |
|
157 | + $arg_mapping = [ |
|
158 | + 'orderBy' => 'order_by', |
|
159 | + 'order' => 'order', |
|
160 | + ]; |
|
161 | + |
|
162 | + /** |
|
163 | + * Return the Query Args |
|
164 | + */ |
|
165 | + return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
166 | + } |
|
167 | 167 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
100 | 100 | */ |
101 | 101 | $input_fields = []; |
102 | - if (! empty($this->args['where'])) { |
|
102 | + if ( ! empty($this->args['where'])) { |
|
103 | 103 | $input_fields = $this->sanitize_input_fields($this->args['where']); |
104 | 104 | } |
105 | 105 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * Merge the input_fields with the default query_args |
132 | 132 | */ |
133 | - if (! empty($input_fields)) { |
|
133 | + if ( ! empty($input_fields)) { |
|
134 | 134 | $query_args = array_merge($query_args, $input_fields); |
135 | 135 | } |
136 | 136 |
@@ -17,137 +17,137 @@ |
||
17 | 17 | class TicketConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @return EEM_Ticket |
|
22 | - * @throws EE_Error |
|
23 | - * @throws InvalidArgumentException |
|
24 | - * @throws InvalidDataTypeException |
|
25 | - * @throws InvalidInterfaceException |
|
26 | - */ |
|
27 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
28 | - public function get_query() |
|
29 | - { |
|
30 | - return EEM_Ticket::instance(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Return an array of items from the query |
|
36 | - * |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
40 | - public function get_items() |
|
41 | - { |
|
42 | - |
|
43 | - $results = $this->query->get_col($this->query_args); |
|
44 | - |
|
45 | - return ! empty($results) ? $results : []; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Determine whether the Query should execute. If it's determined that the query should |
|
51 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
52 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
53 | - * Return false to prevent the query from executing. |
|
54 | - * |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
58 | - public function should_execute() |
|
59 | - { |
|
60 | - |
|
61 | - if (false === $this->should_execute) { |
|
62 | - return false; |
|
63 | - } |
|
64 | - |
|
65 | - return $this->should_execute; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
71 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
72 | - * handle batch resolution of the posts. |
|
73 | - * |
|
74 | - * @return array |
|
75 | - * @throws EE_Error |
|
76 | - * @throws InvalidArgumentException |
|
77 | - * @throws ReflectionException |
|
78 | - * @throws InvalidDataTypeException |
|
79 | - * @throws InvalidInterfaceException |
|
80 | - */ |
|
81 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
82 | - public function get_query_args() |
|
83 | - { |
|
84 | - |
|
85 | - $query_args = []; |
|
86 | - |
|
87 | - /** |
|
88 | - * Prepare for later use |
|
89 | - */ |
|
90 | - $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
91 | - $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
92 | - |
|
93 | - /** |
|
94 | - * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
95 | - */ |
|
96 | - $query_args['limit'] = min( |
|
97 | - max(absint($first), absint($last), 10), |
|
98 | - $this->query_amount |
|
99 | - ) + 1; |
|
100 | - |
|
101 | - /** |
|
102 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
103 | - */ |
|
104 | - $input_fields = []; |
|
105 | - if (! empty($this->args['where'])) { |
|
106 | - $input_fields = $this->sanitize_input_fields($this->args['where']); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
111 | - */ |
|
112 | - if ($this->source instanceof EE_Datetime) { |
|
113 | - $query_args[] = ['Datetime.DTT_ID' => $this->source->ID()]; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Merge the input_fields with the default query_args |
|
118 | - */ |
|
119 | - if (! empty($input_fields)) { |
|
120 | - $query_args = array_merge($query_args, $input_fields); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Return the $query_args |
|
125 | - */ |
|
126 | - return $query_args; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
|
132 | - * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
|
133 | - * this was quick. I'd be down to explore more dynamic ways to map this, but for |
|
134 | - * now this gets the job done. |
|
135 | - * |
|
136 | - * @param array $query_args |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
140 | - public function sanitize_input_fields(array $query_args) |
|
141 | - { |
|
142 | - |
|
143 | - $arg_mapping = [ |
|
144 | - 'orderBy' => 'order_by', |
|
145 | - 'order' => 'order', |
|
146 | - ]; |
|
147 | - |
|
148 | - /** |
|
149 | - * Return the Query Args |
|
150 | - */ |
|
151 | - return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
152 | - } |
|
20 | + /** |
|
21 | + * @return EEM_Ticket |
|
22 | + * @throws EE_Error |
|
23 | + * @throws InvalidArgumentException |
|
24 | + * @throws InvalidDataTypeException |
|
25 | + * @throws InvalidInterfaceException |
|
26 | + */ |
|
27 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
28 | + public function get_query() |
|
29 | + { |
|
30 | + return EEM_Ticket::instance(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Return an array of items from the query |
|
36 | + * |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
40 | + public function get_items() |
|
41 | + { |
|
42 | + |
|
43 | + $results = $this->query->get_col($this->query_args); |
|
44 | + |
|
45 | + return ! empty($results) ? $results : []; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Determine whether the Query should execute. If it's determined that the query should |
|
51 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
52 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
53 | + * Return false to prevent the query from executing. |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
58 | + public function should_execute() |
|
59 | + { |
|
60 | + |
|
61 | + if (false === $this->should_execute) { |
|
62 | + return false; |
|
63 | + } |
|
64 | + |
|
65 | + return $this->should_execute; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
71 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
72 | + * handle batch resolution of the posts. |
|
73 | + * |
|
74 | + * @return array |
|
75 | + * @throws EE_Error |
|
76 | + * @throws InvalidArgumentException |
|
77 | + * @throws ReflectionException |
|
78 | + * @throws InvalidDataTypeException |
|
79 | + * @throws InvalidInterfaceException |
|
80 | + */ |
|
81 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
82 | + public function get_query_args() |
|
83 | + { |
|
84 | + |
|
85 | + $query_args = []; |
|
86 | + |
|
87 | + /** |
|
88 | + * Prepare for later use |
|
89 | + */ |
|
90 | + $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
91 | + $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
92 | + |
|
93 | + /** |
|
94 | + * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
95 | + */ |
|
96 | + $query_args['limit'] = min( |
|
97 | + max(absint($first), absint($last), 10), |
|
98 | + $this->query_amount |
|
99 | + ) + 1; |
|
100 | + |
|
101 | + /** |
|
102 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
103 | + */ |
|
104 | + $input_fields = []; |
|
105 | + if (! empty($this->args['where'])) { |
|
106 | + $input_fields = $this->sanitize_input_fields($this->args['where']); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
111 | + */ |
|
112 | + if ($this->source instanceof EE_Datetime) { |
|
113 | + $query_args[] = ['Datetime.DTT_ID' => $this->source->ID()]; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Merge the input_fields with the default query_args |
|
118 | + */ |
|
119 | + if (! empty($input_fields)) { |
|
120 | + $query_args = array_merge($query_args, $input_fields); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Return the $query_args |
|
125 | + */ |
|
126 | + return $query_args; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
|
132 | + * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
|
133 | + * this was quick. I'd be down to explore more dynamic ways to map this, but for |
|
134 | + * now this gets the job done. |
|
135 | + * |
|
136 | + * @param array $query_args |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
140 | + public function sanitize_input_fields(array $query_args) |
|
141 | + { |
|
142 | + |
|
143 | + $arg_mapping = [ |
|
144 | + 'orderBy' => 'order_by', |
|
145 | + 'order' => 'order', |
|
146 | + ]; |
|
147 | + |
|
148 | + /** |
|
149 | + * Return the Query Args |
|
150 | + */ |
|
151 | + return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
152 | + } |
|
153 | 153 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
103 | 103 | */ |
104 | 104 | $input_fields = []; |
105 | - if (! empty($this->args['where'])) { |
|
105 | + if ( ! empty($this->args['where'])) { |
|
106 | 106 | $input_fields = $this->sanitize_input_fields($this->args['where']); |
107 | 107 | } |
108 | 108 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Merge the input_fields with the default query_args |
118 | 118 | */ |
119 | - if (! empty($input_fields)) { |
|
119 | + if ( ! empty($input_fields)) { |
|
120 | 120 | $query_args = array_merge($query_args, $input_fields); |
121 | 121 | } |
122 | 122 |
@@ -25,257 +25,257 @@ |
||
25 | 25 | class Ticket extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Ticket constructor. |
|
30 | - * |
|
31 | - * @param EEM_Ticket $ticket_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Ticket $ticket_model) |
|
34 | - { |
|
35 | - $this->model = $ticket_model; |
|
36 | - $this->setName('Ticket'); |
|
37 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * Ticket constructor. |
|
30 | + * |
|
31 | + * @param EEM_Ticket $ticket_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Ticket $ticket_model) |
|
34 | + { |
|
35 | + $this->model = $ticket_model; |
|
36 | + $this->setName('Ticket'); |
|
37 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - protected function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'Int'], |
|
53 | - 'ID', |
|
54 | - esc_html__('Ticket ID', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'name', |
|
58 | - 'String', |
|
59 | - 'name', |
|
60 | - esc_html__('Ticket Name', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'description', |
|
64 | - 'String', |
|
65 | - 'description', |
|
66 | - esc_html__('Description of Ticket', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'startDate', |
|
70 | - 'String', |
|
71 | - 'start_date', |
|
72 | - esc_html__('Start time/date of Ticket', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'endDate', |
|
76 | - 'String', |
|
77 | - 'end_date', |
|
78 | - esc_html__('End time/date of Ticket', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'min', |
|
82 | - 'Int', |
|
83 | - 'min', |
|
84 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'max', |
|
88 | - 'Int', |
|
89 | - 'max', |
|
90 | - esc_html__( |
|
91 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
92 | - 'event_espresso' |
|
93 | - ), |
|
94 | - [$this, 'parseInfiniteValue'] |
|
95 | - ), |
|
96 | - new GraphQLField( |
|
97 | - 'price', |
|
98 | - 'Float', |
|
99 | - 'price', |
|
100 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLField( |
|
103 | - 'sold', |
|
104 | - 'Int', |
|
105 | - 'sold', |
|
106 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLField( |
|
109 | - 'quantity', |
|
110 | - 'Int', |
|
111 | - 'qty', |
|
112 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
113 | - [$this, 'parseInfiniteValue'] |
|
114 | - ), |
|
115 | - new GraphQLField( |
|
116 | - 'reserved', |
|
117 | - 'Int', |
|
118 | - 'reserved', |
|
119 | - esc_html__( |
|
120 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
121 | - 'event_espresso' |
|
122 | - ) |
|
123 | - ), |
|
124 | - new GraphQLField( |
|
125 | - 'uses', |
|
126 | - 'Int', |
|
127 | - 'uses', |
|
128 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
129 | - [$this, 'parseInfiniteValue'] |
|
130 | - ), |
|
131 | - new GraphQLField( |
|
132 | - 'isRequired', |
|
133 | - 'Boolean', |
|
134 | - 'required', |
|
135 | - esc_html__( |
|
136 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
137 | - 'event_espresso' |
|
138 | - ) |
|
139 | - ), |
|
140 | - new GraphQLField( |
|
141 | - 'isTaxable', |
|
142 | - 'Boolean', |
|
143 | - 'taxable', |
|
144 | - esc_html__( |
|
145 | - 'Flag indicating whether there is tax applied on this ticket', |
|
146 | - 'event_espresso' |
|
147 | - ) |
|
148 | - ), |
|
149 | - new GraphQLField( |
|
150 | - 'isDefault', |
|
151 | - 'Boolean', |
|
152 | - 'is_default', |
|
153 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
154 | - ), |
|
155 | - new GraphQLField( |
|
156 | - 'order', |
|
157 | - 'Int', |
|
158 | - 'order', |
|
159 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
160 | - ), |
|
161 | - new GraphQLField( |
|
162 | - 'row', |
|
163 | - 'Int', |
|
164 | - 'row', |
|
165 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
166 | - ), |
|
167 | - new GraphQLOutputField( |
|
168 | - 'wpUser', |
|
169 | - 'User', |
|
170 | - null, |
|
171 | - esc_html__('Ticket Creator', 'event_espresso') |
|
172 | - ), |
|
173 | - new GraphQLInputField( |
|
174 | - 'wpUser', |
|
175 | - 'Int', |
|
176 | - null, |
|
177 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
178 | - ), |
|
179 | - new GraphQLOutputField( |
|
180 | - 'parent', |
|
181 | - 'Ticket', |
|
182 | - null, |
|
183 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
184 | - ), |
|
185 | - new GraphQLInputField( |
|
186 | - 'parent', |
|
187 | - 'Int', |
|
188 | - null, |
|
189 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
190 | - ), |
|
191 | - new GraphQLField( |
|
192 | - 'reverseCalculate', |
|
193 | - 'Boolean', |
|
194 | - 'reverse_calculate', |
|
195 | - esc_html__( |
|
196 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
197 | - 'event_espresso' |
|
198 | - ) |
|
199 | - ), |
|
200 | - new GraphQLField( |
|
201 | - 'isFree', |
|
202 | - 'Boolean', |
|
203 | - 'is_free', |
|
204 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
205 | - ), |
|
206 | - new GraphQLOutputField( |
|
207 | - 'event', |
|
208 | - 'Event', |
|
209 | - null, |
|
210 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
211 | - ), |
|
212 | - ]; |
|
213 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + protected function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'Int'], |
|
53 | + 'ID', |
|
54 | + esc_html__('Ticket ID', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'name', |
|
58 | + 'String', |
|
59 | + 'name', |
|
60 | + esc_html__('Ticket Name', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'description', |
|
64 | + 'String', |
|
65 | + 'description', |
|
66 | + esc_html__('Description of Ticket', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'startDate', |
|
70 | + 'String', |
|
71 | + 'start_date', |
|
72 | + esc_html__('Start time/date of Ticket', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'endDate', |
|
76 | + 'String', |
|
77 | + 'end_date', |
|
78 | + esc_html__('End time/date of Ticket', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'min', |
|
82 | + 'Int', |
|
83 | + 'min', |
|
84 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'max', |
|
88 | + 'Int', |
|
89 | + 'max', |
|
90 | + esc_html__( |
|
91 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
92 | + 'event_espresso' |
|
93 | + ), |
|
94 | + [$this, 'parseInfiniteValue'] |
|
95 | + ), |
|
96 | + new GraphQLField( |
|
97 | + 'price', |
|
98 | + 'Float', |
|
99 | + 'price', |
|
100 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLField( |
|
103 | + 'sold', |
|
104 | + 'Int', |
|
105 | + 'sold', |
|
106 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLField( |
|
109 | + 'quantity', |
|
110 | + 'Int', |
|
111 | + 'qty', |
|
112 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
113 | + [$this, 'parseInfiniteValue'] |
|
114 | + ), |
|
115 | + new GraphQLField( |
|
116 | + 'reserved', |
|
117 | + 'Int', |
|
118 | + 'reserved', |
|
119 | + esc_html__( |
|
120 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
121 | + 'event_espresso' |
|
122 | + ) |
|
123 | + ), |
|
124 | + new GraphQLField( |
|
125 | + 'uses', |
|
126 | + 'Int', |
|
127 | + 'uses', |
|
128 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
129 | + [$this, 'parseInfiniteValue'] |
|
130 | + ), |
|
131 | + new GraphQLField( |
|
132 | + 'isRequired', |
|
133 | + 'Boolean', |
|
134 | + 'required', |
|
135 | + esc_html__( |
|
136 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
137 | + 'event_espresso' |
|
138 | + ) |
|
139 | + ), |
|
140 | + new GraphQLField( |
|
141 | + 'isTaxable', |
|
142 | + 'Boolean', |
|
143 | + 'taxable', |
|
144 | + esc_html__( |
|
145 | + 'Flag indicating whether there is tax applied on this ticket', |
|
146 | + 'event_espresso' |
|
147 | + ) |
|
148 | + ), |
|
149 | + new GraphQLField( |
|
150 | + 'isDefault', |
|
151 | + 'Boolean', |
|
152 | + 'is_default', |
|
153 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
154 | + ), |
|
155 | + new GraphQLField( |
|
156 | + 'order', |
|
157 | + 'Int', |
|
158 | + 'order', |
|
159 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
160 | + ), |
|
161 | + new GraphQLField( |
|
162 | + 'row', |
|
163 | + 'Int', |
|
164 | + 'row', |
|
165 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
166 | + ), |
|
167 | + new GraphQLOutputField( |
|
168 | + 'wpUser', |
|
169 | + 'User', |
|
170 | + null, |
|
171 | + esc_html__('Ticket Creator', 'event_espresso') |
|
172 | + ), |
|
173 | + new GraphQLInputField( |
|
174 | + 'wpUser', |
|
175 | + 'Int', |
|
176 | + null, |
|
177 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
178 | + ), |
|
179 | + new GraphQLOutputField( |
|
180 | + 'parent', |
|
181 | + 'Ticket', |
|
182 | + null, |
|
183 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
184 | + ), |
|
185 | + new GraphQLInputField( |
|
186 | + 'parent', |
|
187 | + 'Int', |
|
188 | + null, |
|
189 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
190 | + ), |
|
191 | + new GraphQLField( |
|
192 | + 'reverseCalculate', |
|
193 | + 'Boolean', |
|
194 | + 'reverse_calculate', |
|
195 | + esc_html__( |
|
196 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
197 | + 'event_espresso' |
|
198 | + ) |
|
199 | + ), |
|
200 | + new GraphQLField( |
|
201 | + 'isFree', |
|
202 | + 'Boolean', |
|
203 | + 'is_free', |
|
204 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
205 | + ), |
|
206 | + new GraphQLOutputField( |
|
207 | + 'event', |
|
208 | + 'Event', |
|
209 | + null, |
|
210 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
211 | + ), |
|
212 | + ]; |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | - /** |
|
217 | - * @param array $inputFields The mutation input fields. |
|
218 | - * @throws InvalidArgumentException |
|
219 | - * @throws ReflectionException |
|
220 | - * @since $VID:$ |
|
221 | - */ |
|
222 | - public function registerMutations(array $inputFields) |
|
223 | - { |
|
224 | - // Register mutation to update an entity. |
|
225 | - register_graphql_mutation( |
|
226 | - 'update' . $this->name(), |
|
227 | - [ |
|
228 | - 'inputFields' => $inputFields, |
|
229 | - 'outputFields' => [ |
|
230 | - lcfirst($this->name()) => [ |
|
231 | - 'type' => $this->name(), |
|
232 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
233 | - ], |
|
234 | - ], |
|
235 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
236 | - ] |
|
237 | - ); |
|
238 | - // Register mutation to delete an entity. |
|
239 | - register_graphql_mutation( |
|
240 | - 'delete' . $this->name(), |
|
241 | - [ |
|
242 | - 'inputFields' => [ |
|
243 | - 'id' => $inputFields['id'], |
|
244 | - 'deletePermanently' => [ |
|
245 | - 'type' => 'Boolean', |
|
246 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
247 | - ], |
|
248 | - ], |
|
249 | - 'outputFields' => [ |
|
250 | - lcfirst($this->name()) => [ |
|
251 | - 'type' => $this->name(), |
|
252 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
253 | - 'resolve' => static function ($payload) { |
|
254 | - $deleted = (object) $payload['deleted']; |
|
216 | + /** |
|
217 | + * @param array $inputFields The mutation input fields. |
|
218 | + * @throws InvalidArgumentException |
|
219 | + * @throws ReflectionException |
|
220 | + * @since $VID:$ |
|
221 | + */ |
|
222 | + public function registerMutations(array $inputFields) |
|
223 | + { |
|
224 | + // Register mutation to update an entity. |
|
225 | + register_graphql_mutation( |
|
226 | + 'update' . $this->name(), |
|
227 | + [ |
|
228 | + 'inputFields' => $inputFields, |
|
229 | + 'outputFields' => [ |
|
230 | + lcfirst($this->name()) => [ |
|
231 | + 'type' => $this->name(), |
|
232 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
233 | + ], |
|
234 | + ], |
|
235 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
236 | + ] |
|
237 | + ); |
|
238 | + // Register mutation to delete an entity. |
|
239 | + register_graphql_mutation( |
|
240 | + 'delete' . $this->name(), |
|
241 | + [ |
|
242 | + 'inputFields' => [ |
|
243 | + 'id' => $inputFields['id'], |
|
244 | + 'deletePermanently' => [ |
|
245 | + 'type' => 'Boolean', |
|
246 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
247 | + ], |
|
248 | + ], |
|
249 | + 'outputFields' => [ |
|
250 | + lcfirst($this->name()) => [ |
|
251 | + 'type' => $this->name(), |
|
252 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
253 | + 'resolve' => static function ($payload) { |
|
254 | + $deleted = (object) $payload['deleted']; |
|
255 | 255 | |
256 | - return ! empty($deleted) ? $deleted : null; |
|
257 | - }, |
|
258 | - ], |
|
259 | - ], |
|
260 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
261 | - ] |
|
262 | - ); |
|
256 | + return ! empty($deleted) ? $deleted : null; |
|
257 | + }, |
|
258 | + ], |
|
259 | + ], |
|
260 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
261 | + ] |
|
262 | + ); |
|
263 | 263 | |
264 | - // remove primary key from input. |
|
265 | - unset($inputFields['id']); |
|
266 | - // Register mutation to update an entity. |
|
267 | - register_graphql_mutation( |
|
268 | - 'create' . $this->name(), |
|
269 | - [ |
|
270 | - 'inputFields' => $inputFields, |
|
271 | - 'outputFields' => [ |
|
272 | - lcfirst($this->name()) => [ |
|
273 | - 'type' => $this->name(), |
|
274 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
275 | - ], |
|
276 | - ], |
|
277 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
278 | - ] |
|
279 | - ); |
|
280 | - } |
|
264 | + // remove primary key from input. |
|
265 | + unset($inputFields['id']); |
|
266 | + // Register mutation to update an entity. |
|
267 | + register_graphql_mutation( |
|
268 | + 'create' . $this->name(), |
|
269 | + [ |
|
270 | + 'inputFields' => $inputFields, |
|
271 | + 'outputFields' => [ |
|
272 | + lcfirst($this->name()) => [ |
|
273 | + 'type' => $this->name(), |
|
274 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
275 | + ], |
|
276 | + ], |
|
277 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
278 | + ] |
|
279 | + ); |
|
280 | + } |
|
281 | 281 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | { |
224 | 224 | // Register mutation to update an entity. |
225 | 225 | register_graphql_mutation( |
226 | - 'update' . $this->name(), |
|
226 | + 'update'.$this->name(), |
|
227 | 227 | [ |
228 | 228 | 'inputFields' => $inputFields, |
229 | 229 | 'outputFields' => [ |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | ); |
238 | 238 | // Register mutation to delete an entity. |
239 | 239 | register_graphql_mutation( |
240 | - 'delete' . $this->name(), |
|
240 | + 'delete'.$this->name(), |
|
241 | 241 | [ |
242 | 242 | 'inputFields' => [ |
243 | 243 | 'id' => $inputFields['id'], |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | lcfirst($this->name()) => [ |
251 | 251 | 'type' => $this->name(), |
252 | 252 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
253 | - 'resolve' => static function ($payload) { |
|
253 | + 'resolve' => static function($payload) { |
|
254 | 254 | $deleted = (object) $payload['deleted']; |
255 | 255 | |
256 | 256 | return ! empty($deleted) ? $deleted : null; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | unset($inputFields['id']); |
266 | 266 | // Register mutation to update an entity. |
267 | 267 | register_graphql_mutation( |
268 | - 'create' . $this->name(), |
|
268 | + 'create'.$this->name(), |
|
269 | 269 | [ |
270 | 270 | 'inputFields' => $inputFields, |
271 | 271 | 'outputFields' => [ |
@@ -21,190 +21,190 @@ |
||
21 | 21 | class Event extends TypeBase |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Event constructor. |
|
26 | - * |
|
27 | - * @param EEM_Event $event_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Event $event_model) |
|
30 | - { |
|
31 | - $this->model = $event_model; |
|
32 | - $this->setName('Event'); |
|
33 | - $this->setIsCustomPostType(true); |
|
34 | - parent::__construct(); |
|
35 | - } |
|
24 | + /** |
|
25 | + * Event constructor. |
|
26 | + * |
|
27 | + * @param EEM_Event $event_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Event $event_model) |
|
30 | + { |
|
31 | + $this->model = $event_model; |
|
32 | + $this->setName('Event'); |
|
33 | + $this->setIsCustomPostType(true); |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function getFields() |
|
43 | - { |
|
44 | - return [ |
|
45 | - new GraphQLField( |
|
46 | - 'name', |
|
47 | - 'String', |
|
48 | - 'name', |
|
49 | - esc_html__('Event Name', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLField( |
|
52 | - 'desc', |
|
53 | - 'String', |
|
54 | - 'description', |
|
55 | - esc_html__('Event Description', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLField( |
|
58 | - 'shortDesc', |
|
59 | - 'String', |
|
60 | - 'short_description', |
|
61 | - esc_html__('Event Short Description', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLField( |
|
64 | - 'created', |
|
65 | - 'String', |
|
66 | - 'created', |
|
67 | - esc_html__('Date/Time Event Created', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLOutputField( |
|
70 | - 'wpUser', |
|
71 | - 'User', |
|
72 | - null, |
|
73 | - esc_html__('Event Creator', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLInputField( |
|
76 | - 'wpUser', |
|
77 | - 'Int', |
|
78 | - null, |
|
79 | - esc_html__('Event Creator ID', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLField( |
|
82 | - 'order', |
|
83 | - 'Int', |
|
84 | - 'order', |
|
85 | - esc_html__('Event Menu Order', 'event_espresso') |
|
86 | - ), |
|
87 | - new GraphQLField( |
|
88 | - 'displayDesc', |
|
89 | - 'Boolean', |
|
90 | - 'display_description', |
|
91 | - esc_html__('Display Description Flag', 'event_espresso') |
|
92 | - ), |
|
93 | - new GraphQLField( |
|
94 | - 'displayTicketSelector', |
|
95 | - 'Boolean', |
|
96 | - 'display_ticket_selector', |
|
97 | - esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
98 | - ), |
|
99 | - new GraphQLField( |
|
100 | - 'visibleOn', |
|
101 | - 'String', |
|
102 | - 'visible_on', |
|
103 | - esc_html__('Event Visible Date', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'additionalLimit', |
|
107 | - 'String', |
|
108 | - 'additional_limit', |
|
109 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'phone', |
|
113 | - 'String', |
|
114 | - 'phone', |
|
115 | - esc_html__('Event Phone Number', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'memberOnly', |
|
119 | - 'Boolean', |
|
120 | - 'member_only', |
|
121 | - esc_html__('Member-Only Event Flag', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'allowOverflow', |
|
125 | - 'Boolean', |
|
126 | - 'allow_overflow', |
|
127 | - esc_html__('Allow Overflow on Event', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLField( |
|
130 | - 'timezoneString', |
|
131 | - 'String', |
|
132 | - 'timezone_string', |
|
133 | - esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLField( |
|
136 | - 'externalUrl', |
|
137 | - 'String', |
|
138 | - 'external_url', |
|
139 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
140 | - ), |
|
141 | - new GraphQLField( |
|
142 | - 'donations', |
|
143 | - 'Boolean', |
|
144 | - 'donations', |
|
145 | - esc_html__('Accept Donations?', 'event_espresso') |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'isSoldOut', |
|
149 | - 'Boolean', |
|
150 | - 'is_sold_out', |
|
151 | - esc_html__( |
|
152 | - 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
153 | - 'event_espresso' |
|
154 | - ) |
|
155 | - ), |
|
156 | - new GraphQLField( |
|
157 | - 'isPostponed', |
|
158 | - 'Boolean', |
|
159 | - 'is_postponed', |
|
160 | - esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
161 | - ), |
|
162 | - new GraphQLField( |
|
163 | - 'isCancelled', |
|
164 | - 'Boolean', |
|
165 | - 'is_cancelled', |
|
166 | - esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLField( |
|
169 | - 'isUpcoming', |
|
170 | - 'Boolean', |
|
171 | - 'is_upcoming', |
|
172 | - esc_html__('Whether the event is upcoming', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLField( |
|
175 | - 'isActive', |
|
176 | - 'Boolean', |
|
177 | - 'is_active', |
|
178 | - esc_html__('Flag indicating event is active', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLField( |
|
181 | - 'isInactive', |
|
182 | - 'Boolean', |
|
183 | - 'is_inactive', |
|
184 | - esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
185 | - ), |
|
186 | - new GraphQLField( |
|
187 | - 'isExpired', |
|
188 | - 'Boolean', |
|
189 | - 'is_expired', |
|
190 | - esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
191 | - ), |
|
192 | - ]; |
|
193 | - } |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function getFields() |
|
43 | + { |
|
44 | + return [ |
|
45 | + new GraphQLField( |
|
46 | + 'name', |
|
47 | + 'String', |
|
48 | + 'name', |
|
49 | + esc_html__('Event Name', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLField( |
|
52 | + 'desc', |
|
53 | + 'String', |
|
54 | + 'description', |
|
55 | + esc_html__('Event Description', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLField( |
|
58 | + 'shortDesc', |
|
59 | + 'String', |
|
60 | + 'short_description', |
|
61 | + esc_html__('Event Short Description', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLField( |
|
64 | + 'created', |
|
65 | + 'String', |
|
66 | + 'created', |
|
67 | + esc_html__('Date/Time Event Created', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLOutputField( |
|
70 | + 'wpUser', |
|
71 | + 'User', |
|
72 | + null, |
|
73 | + esc_html__('Event Creator', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLInputField( |
|
76 | + 'wpUser', |
|
77 | + 'Int', |
|
78 | + null, |
|
79 | + esc_html__('Event Creator ID', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLField( |
|
82 | + 'order', |
|
83 | + 'Int', |
|
84 | + 'order', |
|
85 | + esc_html__('Event Menu Order', 'event_espresso') |
|
86 | + ), |
|
87 | + new GraphQLField( |
|
88 | + 'displayDesc', |
|
89 | + 'Boolean', |
|
90 | + 'display_description', |
|
91 | + esc_html__('Display Description Flag', 'event_espresso') |
|
92 | + ), |
|
93 | + new GraphQLField( |
|
94 | + 'displayTicketSelector', |
|
95 | + 'Boolean', |
|
96 | + 'display_ticket_selector', |
|
97 | + esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
98 | + ), |
|
99 | + new GraphQLField( |
|
100 | + 'visibleOn', |
|
101 | + 'String', |
|
102 | + 'visible_on', |
|
103 | + esc_html__('Event Visible Date', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'additionalLimit', |
|
107 | + 'String', |
|
108 | + 'additional_limit', |
|
109 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'phone', |
|
113 | + 'String', |
|
114 | + 'phone', |
|
115 | + esc_html__('Event Phone Number', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'memberOnly', |
|
119 | + 'Boolean', |
|
120 | + 'member_only', |
|
121 | + esc_html__('Member-Only Event Flag', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'allowOverflow', |
|
125 | + 'Boolean', |
|
126 | + 'allow_overflow', |
|
127 | + esc_html__('Allow Overflow on Event', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLField( |
|
130 | + 'timezoneString', |
|
131 | + 'String', |
|
132 | + 'timezone_string', |
|
133 | + esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLField( |
|
136 | + 'externalUrl', |
|
137 | + 'String', |
|
138 | + 'external_url', |
|
139 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
140 | + ), |
|
141 | + new GraphQLField( |
|
142 | + 'donations', |
|
143 | + 'Boolean', |
|
144 | + 'donations', |
|
145 | + esc_html__('Accept Donations?', 'event_espresso') |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'isSoldOut', |
|
149 | + 'Boolean', |
|
150 | + 'is_sold_out', |
|
151 | + esc_html__( |
|
152 | + 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
153 | + 'event_espresso' |
|
154 | + ) |
|
155 | + ), |
|
156 | + new GraphQLField( |
|
157 | + 'isPostponed', |
|
158 | + 'Boolean', |
|
159 | + 'is_postponed', |
|
160 | + esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
161 | + ), |
|
162 | + new GraphQLField( |
|
163 | + 'isCancelled', |
|
164 | + 'Boolean', |
|
165 | + 'is_cancelled', |
|
166 | + esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLField( |
|
169 | + 'isUpcoming', |
|
170 | + 'Boolean', |
|
171 | + 'is_upcoming', |
|
172 | + esc_html__('Whether the event is upcoming', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLField( |
|
175 | + 'isActive', |
|
176 | + 'Boolean', |
|
177 | + 'is_active', |
|
178 | + esc_html__('Flag indicating event is active', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLField( |
|
181 | + 'isInactive', |
|
182 | + 'Boolean', |
|
183 | + 'is_inactive', |
|
184 | + esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
185 | + ), |
|
186 | + new GraphQLField( |
|
187 | + 'isExpired', |
|
188 | + 'Boolean', |
|
189 | + 'is_expired', |
|
190 | + esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
191 | + ), |
|
192 | + ]; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | - /** |
|
197 | - * Extends the existing WP GraphQL mutations. |
|
198 | - * |
|
199 | - * @since $VID:$ |
|
200 | - */ |
|
201 | - public function extendMutations() |
|
202 | - { |
|
203 | - add_action( |
|
204 | - 'graphql_post_object_mutation_update_additional_data', |
|
205 | - EventUpdate::mutateFields($this->model, $this), |
|
206 | - 10, |
|
207 | - 6 |
|
208 | - ); |
|
209 | - } |
|
196 | + /** |
|
197 | + * Extends the existing WP GraphQL mutations. |
|
198 | + * |
|
199 | + * @since $VID:$ |
|
200 | + */ |
|
201 | + public function extendMutations() |
|
202 | + { |
|
203 | + add_action( |
|
204 | + 'graphql_post_object_mutation_update_additional_data', |
|
205 | + EventUpdate::mutateFields($this->model, $this), |
|
206 | + 10, |
|
207 | + 6 |
|
208 | + ); |
|
209 | + } |
|
210 | 210 | } |
@@ -25,237 +25,237 @@ |
||
25 | 25 | class Datetime extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * EventDate constructor. |
|
30 | - * |
|
31 | - * @param EEM_Datetime $datetime_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Datetime $datetime_model) |
|
34 | - { |
|
35 | - $this->model = $datetime_model; |
|
36 | - $this->setName('Datetime'); |
|
37 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * EventDate constructor. |
|
30 | + * |
|
31 | + * @param EEM_Datetime $datetime_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Datetime $datetime_model) |
|
34 | + { |
|
35 | + $this->model = $datetime_model; |
|
36 | + $this->setName('Datetime'); |
|
37 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - public function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'Int'], |
|
53 | - 'ID', |
|
54 | - esc_html__('The datetime ID.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'name', |
|
58 | - 'String', |
|
59 | - 'name', |
|
60 | - esc_html__('Datetime Name', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'description', |
|
64 | - 'String', |
|
65 | - 'description', |
|
66 | - esc_html__('Description for Datetime', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'start', |
|
70 | - 'String', |
|
71 | - 'start', |
|
72 | - esc_html__('Start timestamp of Event', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'startDate', |
|
76 | - 'String', |
|
77 | - 'start_date', |
|
78 | - esc_html__('Start time/date of Event', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'end', |
|
82 | - 'String', |
|
83 | - 'end', |
|
84 | - esc_html__('End timestamp of Event', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'endDate', |
|
88 | - 'String', |
|
89 | - 'end_date', |
|
90 | - esc_html__('End time/date of Event', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLField( |
|
93 | - 'startTime', |
|
94 | - 'String', |
|
95 | - 'start_time', |
|
96 | - esc_html__('Start time of Event', 'event_espresso') |
|
97 | - ), |
|
98 | - new GraphQLField( |
|
99 | - 'endTime', |
|
100 | - 'String', |
|
101 | - 'end_time', |
|
102 | - esc_html__('End time of Event', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLField( |
|
105 | - 'capacity', |
|
106 | - 'Int', |
|
107 | - 'reg_limit', |
|
108 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
109 | - [$this, 'parseInfiniteValue'] |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'sold', |
|
113 | - 'Int', |
|
114 | - 'sold', |
|
115 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'reserved', |
|
119 | - 'Int', |
|
120 | - 'reserved', |
|
121 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'order', |
|
125 | - 'Int', |
|
126 | - 'order', |
|
127 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLField( |
|
130 | - 'length', |
|
131 | - 'Int', |
|
132 | - 'length', |
|
133 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLOutputField( |
|
136 | - 'parent', |
|
137 | - 'Datetime', |
|
138 | - null, |
|
139 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
140 | - ), |
|
141 | - new GraphQLInputField( |
|
142 | - 'parent', |
|
143 | - 'Int', |
|
144 | - null, |
|
145 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'isPrimary', |
|
149 | - 'Boolean', |
|
150 | - 'is_primary', |
|
151 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
152 | - ), |
|
153 | - new GraphQLField( |
|
154 | - 'isSoldOut', |
|
155 | - 'Boolean', |
|
156 | - 'sold_out', |
|
157 | - esc_html__( |
|
158 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
159 | - 'event_espresso' |
|
160 | - ) |
|
161 | - ), |
|
162 | - new GraphQLField( |
|
163 | - 'isUpcoming', |
|
164 | - 'Boolean', |
|
165 | - 'is_upcoming', |
|
166 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLField( |
|
169 | - 'isActive', |
|
170 | - 'Boolean', |
|
171 | - 'is_active', |
|
172 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLField( |
|
175 | - 'isExpired', |
|
176 | - 'Boolean', |
|
177 | - 'is_expired', |
|
178 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLOutputField( |
|
181 | - 'event', |
|
182 | - 'Event', |
|
183 | - null, |
|
184 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
185 | - ), |
|
186 | - new GraphQLInputField( |
|
187 | - 'event', |
|
188 | - 'Int', |
|
189 | - null, |
|
190 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
191 | - ), |
|
192 | - ]; |
|
193 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + public function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'Int'], |
|
53 | + 'ID', |
|
54 | + esc_html__('The datetime ID.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'name', |
|
58 | + 'String', |
|
59 | + 'name', |
|
60 | + esc_html__('Datetime Name', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'description', |
|
64 | + 'String', |
|
65 | + 'description', |
|
66 | + esc_html__('Description for Datetime', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'start', |
|
70 | + 'String', |
|
71 | + 'start', |
|
72 | + esc_html__('Start timestamp of Event', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'startDate', |
|
76 | + 'String', |
|
77 | + 'start_date', |
|
78 | + esc_html__('Start time/date of Event', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'end', |
|
82 | + 'String', |
|
83 | + 'end', |
|
84 | + esc_html__('End timestamp of Event', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'endDate', |
|
88 | + 'String', |
|
89 | + 'end_date', |
|
90 | + esc_html__('End time/date of Event', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLField( |
|
93 | + 'startTime', |
|
94 | + 'String', |
|
95 | + 'start_time', |
|
96 | + esc_html__('Start time of Event', 'event_espresso') |
|
97 | + ), |
|
98 | + new GraphQLField( |
|
99 | + 'endTime', |
|
100 | + 'String', |
|
101 | + 'end_time', |
|
102 | + esc_html__('End time of Event', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLField( |
|
105 | + 'capacity', |
|
106 | + 'Int', |
|
107 | + 'reg_limit', |
|
108 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
109 | + [$this, 'parseInfiniteValue'] |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'sold', |
|
113 | + 'Int', |
|
114 | + 'sold', |
|
115 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'reserved', |
|
119 | + 'Int', |
|
120 | + 'reserved', |
|
121 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'order', |
|
125 | + 'Int', |
|
126 | + 'order', |
|
127 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLField( |
|
130 | + 'length', |
|
131 | + 'Int', |
|
132 | + 'length', |
|
133 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLOutputField( |
|
136 | + 'parent', |
|
137 | + 'Datetime', |
|
138 | + null, |
|
139 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
140 | + ), |
|
141 | + new GraphQLInputField( |
|
142 | + 'parent', |
|
143 | + 'Int', |
|
144 | + null, |
|
145 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'isPrimary', |
|
149 | + 'Boolean', |
|
150 | + 'is_primary', |
|
151 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
152 | + ), |
|
153 | + new GraphQLField( |
|
154 | + 'isSoldOut', |
|
155 | + 'Boolean', |
|
156 | + 'sold_out', |
|
157 | + esc_html__( |
|
158 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
159 | + 'event_espresso' |
|
160 | + ) |
|
161 | + ), |
|
162 | + new GraphQLField( |
|
163 | + 'isUpcoming', |
|
164 | + 'Boolean', |
|
165 | + 'is_upcoming', |
|
166 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLField( |
|
169 | + 'isActive', |
|
170 | + 'Boolean', |
|
171 | + 'is_active', |
|
172 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLField( |
|
175 | + 'isExpired', |
|
176 | + 'Boolean', |
|
177 | + 'is_expired', |
|
178 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLOutputField( |
|
181 | + 'event', |
|
182 | + 'Event', |
|
183 | + null, |
|
184 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
185 | + ), |
|
186 | + new GraphQLInputField( |
|
187 | + 'event', |
|
188 | + 'Int', |
|
189 | + null, |
|
190 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
191 | + ), |
|
192 | + ]; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | - /** |
|
197 | - * @param array $inputFields The mutation input fields. |
|
198 | - * @throws InvalidArgumentException |
|
199 | - * @throws ReflectionException |
|
200 | - * @since $VID:$ |
|
201 | - */ |
|
202 | - public function registerMutations(array $inputFields) |
|
203 | - { |
|
204 | - // Register mutation to update an entity. |
|
205 | - register_graphql_mutation( |
|
206 | - 'update' . $this->name(), |
|
207 | - [ |
|
208 | - 'inputFields' => $inputFields, |
|
209 | - 'outputFields' => [ |
|
210 | - lcfirst($this->name()) => [ |
|
211 | - 'type' => $this->name(), |
|
212 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
213 | - ], |
|
214 | - ], |
|
215 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
216 | - ] |
|
217 | - ); |
|
218 | - // Register mutation to delete an entity. |
|
219 | - register_graphql_mutation( |
|
220 | - 'delete' . $this->name(), |
|
221 | - [ |
|
222 | - 'inputFields' => [ |
|
223 | - 'id' => $inputFields['id'], |
|
224 | - 'deletePermanently' => [ |
|
225 | - 'type' => 'Boolean', |
|
226 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
227 | - ], |
|
228 | - ], |
|
229 | - 'outputFields' => [ |
|
230 | - lcfirst($this->name()) => [ |
|
231 | - 'type' => $this->name(), |
|
232 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
233 | - 'resolve' => static function ($payload) { |
|
234 | - $deleted = (object) $payload['deleted']; |
|
196 | + /** |
|
197 | + * @param array $inputFields The mutation input fields. |
|
198 | + * @throws InvalidArgumentException |
|
199 | + * @throws ReflectionException |
|
200 | + * @since $VID:$ |
|
201 | + */ |
|
202 | + public function registerMutations(array $inputFields) |
|
203 | + { |
|
204 | + // Register mutation to update an entity. |
|
205 | + register_graphql_mutation( |
|
206 | + 'update' . $this->name(), |
|
207 | + [ |
|
208 | + 'inputFields' => $inputFields, |
|
209 | + 'outputFields' => [ |
|
210 | + lcfirst($this->name()) => [ |
|
211 | + 'type' => $this->name(), |
|
212 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
213 | + ], |
|
214 | + ], |
|
215 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
216 | + ] |
|
217 | + ); |
|
218 | + // Register mutation to delete an entity. |
|
219 | + register_graphql_mutation( |
|
220 | + 'delete' . $this->name(), |
|
221 | + [ |
|
222 | + 'inputFields' => [ |
|
223 | + 'id' => $inputFields['id'], |
|
224 | + 'deletePermanently' => [ |
|
225 | + 'type' => 'Boolean', |
|
226 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
227 | + ], |
|
228 | + ], |
|
229 | + 'outputFields' => [ |
|
230 | + lcfirst($this->name()) => [ |
|
231 | + 'type' => $this->name(), |
|
232 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
233 | + 'resolve' => static function ($payload) { |
|
234 | + $deleted = (object) $payload['deleted']; |
|
235 | 235 | |
236 | - return ! empty($deleted) ? $deleted : null; |
|
237 | - }, |
|
238 | - ], |
|
239 | - ], |
|
240 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
241 | - ] |
|
242 | - ); |
|
236 | + return ! empty($deleted) ? $deleted : null; |
|
237 | + }, |
|
238 | + ], |
|
239 | + ], |
|
240 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
241 | + ] |
|
242 | + ); |
|
243 | 243 | |
244 | - // remove primary key from input. |
|
245 | - unset($inputFields['id']); |
|
246 | - // Register mutation to update an entity. |
|
247 | - register_graphql_mutation( |
|
248 | - 'create' . $this->name(), |
|
249 | - [ |
|
250 | - 'inputFields' => $inputFields, |
|
251 | - 'outputFields' => [ |
|
252 | - lcfirst($this->name()) => [ |
|
253 | - 'type' => $this->name(), |
|
254 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
255 | - ], |
|
256 | - ], |
|
257 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
258 | - ] |
|
259 | - ); |
|
260 | - } |
|
244 | + // remove primary key from input. |
|
245 | + unset($inputFields['id']); |
|
246 | + // Register mutation to update an entity. |
|
247 | + register_graphql_mutation( |
|
248 | + 'create' . $this->name(), |
|
249 | + [ |
|
250 | + 'inputFields' => $inputFields, |
|
251 | + 'outputFields' => [ |
|
252 | + lcfirst($this->name()) => [ |
|
253 | + 'type' => $this->name(), |
|
254 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
255 | + ], |
|
256 | + ], |
|
257 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
258 | + ] |
|
259 | + ); |
|
260 | + } |
|
261 | 261 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | // Register mutation to update an entity. |
205 | 205 | register_graphql_mutation( |
206 | - 'update' . $this->name(), |
|
206 | + 'update'.$this->name(), |
|
207 | 207 | [ |
208 | 208 | 'inputFields' => $inputFields, |
209 | 209 | 'outputFields' => [ |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | ); |
218 | 218 | // Register mutation to delete an entity. |
219 | 219 | register_graphql_mutation( |
220 | - 'delete' . $this->name(), |
|
220 | + 'delete'.$this->name(), |
|
221 | 221 | [ |
222 | 222 | 'inputFields' => [ |
223 | 223 | 'id' => $inputFields['id'], |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | lcfirst($this->name()) => [ |
231 | 231 | 'type' => $this->name(), |
232 | 232 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
233 | - 'resolve' => static function ($payload) { |
|
233 | + 'resolve' => static function($payload) { |
|
234 | 234 | $deleted = (object) $payload['deleted']; |
235 | 235 | |
236 | 236 | return ! empty($deleted) ? $deleted : null; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | unset($inputFields['id']); |
246 | 246 | // Register mutation to update an entity. |
247 | 247 | register_graphql_mutation( |
248 | - 'create' . $this->name(), |
|
248 | + 'create'.$this->name(), |
|
249 | 249 | [ |
250 | 250 | 'inputFields' => $inputFields, |
251 | 251 | 'outputFields' => [ |
@@ -18,103 +18,103 @@ |
||
18 | 18 | class Country extends TypeBase |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Country constructor. |
|
23 | - * |
|
24 | - * @param EEM_Country $country_model |
|
25 | - */ |
|
26 | - public function __construct(EEM_Country $country_model) |
|
27 | - { |
|
28 | - $this->model = $country_model; |
|
29 | - $this->setName('Country'); |
|
30 | - $this->setDescription(__('A country', 'event_espresso')); |
|
31 | - $this->setIsCustomPostType(false); |
|
32 | - parent::__construct(); |
|
33 | - } |
|
21 | + /** |
|
22 | + * Country constructor. |
|
23 | + * |
|
24 | + * @param EEM_Country $country_model |
|
25 | + */ |
|
26 | + public function __construct(EEM_Country $country_model) |
|
27 | + { |
|
28 | + $this->model = $country_model; |
|
29 | + $this->setName('Country'); |
|
30 | + $this->setDescription(__('A country', 'event_espresso')); |
|
31 | + $this->setIsCustomPostType(false); |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @return GraphQLFieldInterface[] |
|
38 | - * @since $VID:$ |
|
39 | - */ |
|
40 | - public function getFields() |
|
41 | - { |
|
42 | - return [ |
|
43 | - new GraphQLField( |
|
44 | - 'isActive', |
|
45 | - 'Boolean', |
|
46 | - null, // 'active', |
|
47 | - esc_html__( |
|
48 | - 'Flag that indicates if the country should appear in dropdown select lists', |
|
49 | - 'event_espresso' |
|
50 | - ) |
|
51 | - ), |
|
52 | - new GraphQLField( |
|
53 | - 'ISO', |
|
54 | - 'String', |
|
55 | - null, // 'ISO', |
|
56 | - esc_html__('Country ISO Code', 'event_espresso') |
|
57 | - ), |
|
58 | - new GraphQLField( |
|
59 | - 'ISO3', |
|
60 | - 'String', |
|
61 | - null, // 'ISO3', |
|
62 | - esc_html__('Country ISO3 Code', 'event_espresso') |
|
63 | - ), |
|
64 | - new GraphQLField( |
|
65 | - 'name', |
|
66 | - 'String', |
|
67 | - 'name', |
|
68 | - esc_html__('Country Name', 'event_espresso') |
|
69 | - ), |
|
70 | - new GraphQLField( |
|
71 | - 'currencyCode', |
|
72 | - 'String', |
|
73 | - 'currency_code', |
|
74 | - esc_html__('Country Currency Code', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLField( |
|
77 | - 'currencySingular', |
|
78 | - 'String', |
|
79 | - 'currency_name_single', |
|
80 | - esc_html__('Currency Name Singular', 'event_espresso') |
|
81 | - ), |
|
82 | - new GraphQLField( |
|
83 | - 'currencyPlural', |
|
84 | - 'String', |
|
85 | - 'currency_name_plural', |
|
86 | - esc_html__('Currency Name Plural', 'event_espresso') |
|
87 | - ), |
|
88 | - new GraphQLField( |
|
89 | - 'currencySign', |
|
90 | - 'String', |
|
91 | - 'currency_sign', |
|
92 | - __('Currency Sign', 'event_espresso') |
|
93 | - ), |
|
94 | - new GraphQLField( |
|
95 | - 'currencySignBeforeNumber', |
|
96 | - 'String', |
|
97 | - 'currency_sign_before', |
|
98 | - esc_html__('Currency Sign Before Number', 'event_espresso') |
|
99 | - ), |
|
100 | - new GraphQLField( |
|
101 | - 'currencyDecimalPlaces', |
|
102 | - 'String', |
|
103 | - 'currency_decimal_places', |
|
104 | - esc_html__('Currency Decimal Places', 'event_espresso') |
|
105 | - ), |
|
106 | - new GraphQLField( |
|
107 | - 'currencyDecimalMark', |
|
108 | - 'String', |
|
109 | - 'currency_decimal_mark', |
|
110 | - esc_html__('Currency Decimal Mark', 'event_espresso') |
|
111 | - ), |
|
112 | - new GraphQLField( |
|
113 | - 'currencyThousandsSeparator', |
|
114 | - 'String', |
|
115 | - 'currency_thousands_separator', |
|
116 | - esc_html__('Currency Thousands Separator', 'event_espresso') |
|
117 | - ), |
|
118 | - ]; |
|
119 | - } |
|
36 | + /** |
|
37 | + * @return GraphQLFieldInterface[] |
|
38 | + * @since $VID:$ |
|
39 | + */ |
|
40 | + public function getFields() |
|
41 | + { |
|
42 | + return [ |
|
43 | + new GraphQLField( |
|
44 | + 'isActive', |
|
45 | + 'Boolean', |
|
46 | + null, // 'active', |
|
47 | + esc_html__( |
|
48 | + 'Flag that indicates if the country should appear in dropdown select lists', |
|
49 | + 'event_espresso' |
|
50 | + ) |
|
51 | + ), |
|
52 | + new GraphQLField( |
|
53 | + 'ISO', |
|
54 | + 'String', |
|
55 | + null, // 'ISO', |
|
56 | + esc_html__('Country ISO Code', 'event_espresso') |
|
57 | + ), |
|
58 | + new GraphQLField( |
|
59 | + 'ISO3', |
|
60 | + 'String', |
|
61 | + null, // 'ISO3', |
|
62 | + esc_html__('Country ISO3 Code', 'event_espresso') |
|
63 | + ), |
|
64 | + new GraphQLField( |
|
65 | + 'name', |
|
66 | + 'String', |
|
67 | + 'name', |
|
68 | + esc_html__('Country Name', 'event_espresso') |
|
69 | + ), |
|
70 | + new GraphQLField( |
|
71 | + 'currencyCode', |
|
72 | + 'String', |
|
73 | + 'currency_code', |
|
74 | + esc_html__('Country Currency Code', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLField( |
|
77 | + 'currencySingular', |
|
78 | + 'String', |
|
79 | + 'currency_name_single', |
|
80 | + esc_html__('Currency Name Singular', 'event_espresso') |
|
81 | + ), |
|
82 | + new GraphQLField( |
|
83 | + 'currencyPlural', |
|
84 | + 'String', |
|
85 | + 'currency_name_plural', |
|
86 | + esc_html__('Currency Name Plural', 'event_espresso') |
|
87 | + ), |
|
88 | + new GraphQLField( |
|
89 | + 'currencySign', |
|
90 | + 'String', |
|
91 | + 'currency_sign', |
|
92 | + __('Currency Sign', 'event_espresso') |
|
93 | + ), |
|
94 | + new GraphQLField( |
|
95 | + 'currencySignBeforeNumber', |
|
96 | + 'String', |
|
97 | + 'currency_sign_before', |
|
98 | + esc_html__('Currency Sign Before Number', 'event_espresso') |
|
99 | + ), |
|
100 | + new GraphQLField( |
|
101 | + 'currencyDecimalPlaces', |
|
102 | + 'String', |
|
103 | + 'currency_decimal_places', |
|
104 | + esc_html__('Currency Decimal Places', 'event_espresso') |
|
105 | + ), |
|
106 | + new GraphQLField( |
|
107 | + 'currencyDecimalMark', |
|
108 | + 'String', |
|
109 | + 'currency_decimal_mark', |
|
110 | + esc_html__('Currency Decimal Mark', 'event_espresso') |
|
111 | + ), |
|
112 | + new GraphQLField( |
|
113 | + 'currencyThousandsSeparator', |
|
114 | + 'String', |
|
115 | + 'currency_thousands_separator', |
|
116 | + esc_html__('Currency Thousands Separator', 'event_espresso') |
|
117 | + ), |
|
118 | + ]; |
|
119 | + } |
|
120 | 120 | } |
@@ -11,27 +11,27 @@ |
||
11 | 11 | class TicketMutation |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Maps the GraphQL input to a format that the model functions can use |
|
16 | - * |
|
17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public static function prepareFields(array $input) |
|
21 | - { |
|
14 | + /** |
|
15 | + * Maps the GraphQL input to a format that the model functions can use |
|
16 | + * |
|
17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public static function prepareFields(array $input) |
|
21 | + { |
|
22 | 22 | |
23 | - $args = []; |
|
23 | + $args = []; |
|
24 | 24 | |
25 | - if (! empty($input['name'])) { |
|
26 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
27 | - } |
|
25 | + if (! empty($input['name'])) { |
|
26 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
27 | + } |
|
28 | 28 | |
29 | - if (! empty($input['description'])) { |
|
30 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
31 | - } |
|
29 | + if (! empty($input['description'])) { |
|
30 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
31 | + } |
|
32 | 32 | |
33 | - // Likewise the other fields... |
|
33 | + // Likewise the other fields... |
|
34 | 34 | |
35 | - return $args; |
|
36 | - } |
|
35 | + return $args; |
|
36 | + } |
|
37 | 37 | } |
@@ -22,11 +22,11 @@ |
||
22 | 22 | |
23 | 23 | $args = []; |
24 | 24 | |
25 | - if (! empty($input['name'])) { |
|
25 | + if ( ! empty($input['name'])) { |
|
26 | 26 | $args['TKT_name'] = sanitize_text_field($input['name']); |
27 | 27 | } |
28 | 28 | |
29 | - if (! empty($input['description'])) { |
|
29 | + if ( ! empty($input['description'])) { |
|
30 | 30 | $args['TKT_description'] = sanitize_text_field($input['description']); |
31 | 31 | } |
32 | 32 |
@@ -11,32 +11,32 @@ |
||
11 | 11 | class VenueMutation |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Maps the GraphQL input to a format that the model functions can use |
|
16 | - * |
|
17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
18 | - * @param string $mutation_name Name of the mutation being performed |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public static function prepareFields(array $input, $mutation_name) |
|
22 | - { |
|
23 | - |
|
24 | - $args = []; |
|
25 | - |
|
26 | - if (! empty($input['name'])) { |
|
27 | - $args['VNU_name'] = sanitize_text_field($input['name']); |
|
28 | - } |
|
29 | - |
|
30 | - if (! empty($input['desc'])) { |
|
31 | - $args['VNU_desc'] = sanitize_text_field($input['desc']); |
|
32 | - } |
|
33 | - |
|
34 | - if (! empty($input['shortDesc'])) { |
|
35 | - $args['VNU_short_desc'] = sanitize_text_field($input['shortDesc']); |
|
36 | - } |
|
37 | - |
|
38 | - // Likewise the other fields... |
|
39 | - |
|
40 | - return $args; |
|
41 | - } |
|
14 | + /** |
|
15 | + * Maps the GraphQL input to a format that the model functions can use |
|
16 | + * |
|
17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
18 | + * @param string $mutation_name Name of the mutation being performed |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public static function prepareFields(array $input, $mutation_name) |
|
22 | + { |
|
23 | + |
|
24 | + $args = []; |
|
25 | + |
|
26 | + if (! empty($input['name'])) { |
|
27 | + $args['VNU_name'] = sanitize_text_field($input['name']); |
|
28 | + } |
|
29 | + |
|
30 | + if (! empty($input['desc'])) { |
|
31 | + $args['VNU_desc'] = sanitize_text_field($input['desc']); |
|
32 | + } |
|
33 | + |
|
34 | + if (! empty($input['shortDesc'])) { |
|
35 | + $args['VNU_short_desc'] = sanitize_text_field($input['shortDesc']); |
|
36 | + } |
|
37 | + |
|
38 | + // Likewise the other fields... |
|
39 | + |
|
40 | + return $args; |
|
41 | + } |
|
42 | 42 | } |
@@ -23,15 +23,15 @@ |
||
23 | 23 | |
24 | 24 | $args = []; |
25 | 25 | |
26 | - if (! empty($input['name'])) { |
|
26 | + if ( ! empty($input['name'])) { |
|
27 | 27 | $args['VNU_name'] = sanitize_text_field($input['name']); |
28 | 28 | } |
29 | 29 | |
30 | - if (! empty($input['desc'])) { |
|
30 | + if ( ! empty($input['desc'])) { |
|
31 | 31 | $args['VNU_desc'] = sanitize_text_field($input['desc']); |
32 | 32 | } |
33 | 33 | |
34 | - if (! empty($input['shortDesc'])) { |
|
34 | + if ( ! empty($input['shortDesc'])) { |
|
35 | 35 | $args['VNU_short_desc'] = sanitize_text_field($input['shortDesc']); |
36 | 36 | } |
37 | 37 |