@@ -16,145 +16,145 @@ |
||
16 | 16 | class PriceConnectionResolver extends AbstractConnectionResolver |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return EEM_Price |
|
21 | - * @throws EE_Error |
|
22 | - * @throws InvalidArgumentException |
|
23 | - * @throws InvalidDataTypeException |
|
24 | - * @throws InvalidInterfaceException |
|
25 | - */ |
|
26 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
27 | - public function get_query() |
|
28 | - { |
|
29 | - return EEM_Price::instance(); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Return an array of items from the query |
|
35 | - * |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
39 | - public function get_items() |
|
40 | - { |
|
41 | - $results = $this->query->get_col($this->query_args); |
|
42 | - |
|
43 | - return ! empty($results) ? $results : []; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Determine whether the Query should execute. If it's determined that the query should |
|
49 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
50 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
51 | - * Return false to prevent the query from executing. |
|
52 | - * |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
56 | - public function should_execute() |
|
57 | - { |
|
58 | - if ($this->should_execute === false) { |
|
59 | - return false; |
|
60 | - } |
|
61 | - |
|
62 | - return $this->should_execute; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
68 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
69 | - * handle batch resolution of the posts. |
|
70 | - * |
|
71 | - * @return array |
|
72 | - * @throws EE_Error |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws ReflectionException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - */ |
|
78 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | - public function get_query_args() |
|
80 | - { |
|
81 | - $where_params = []; |
|
82 | - $query_args = []; |
|
83 | - |
|
84 | - $query_args['limit'] = $this->getLimit(); |
|
85 | - |
|
86 | - // Avoid multiple entries by join. |
|
87 | - $query_args['group_by'] = 'PRC_ID'; |
|
88 | - |
|
89 | - /** |
|
90 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
91 | - */ |
|
92 | - $input_fields = []; |
|
93 | - if (! empty($this->args['where'])) { |
|
94 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
95 | - |
|
96 | - // Use the proper operator. |
|
97 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
98 | - $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
99 | - } |
|
100 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
101 | - $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
102 | - } |
|
103 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
104 | - $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
110 | - */ |
|
111 | - if ($this->source instanceof EE_Ticket) { |
|
112 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Merge the input_fields with the default query_args |
|
117 | - */ |
|
118 | - if (! empty($input_fields)) { |
|
119 | - $where_params = array_merge($where_params, $input_fields); |
|
120 | - } |
|
121 | - |
|
122 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
123 | - |
|
124 | - $query_args[] = $where_params; |
|
125 | - |
|
126 | - /** |
|
127 | - * Return the $query_args |
|
128 | - */ |
|
129 | - return $query_args; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
135 | - * friendly keys. |
|
136 | - * |
|
137 | - * @param array $where_args |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - public function sanitizeInputFields(array $where_args) |
|
141 | - { |
|
142 | - $arg_mapping = [ |
|
143 | - 'ticket' => 'Ticket.TKT_ID', |
|
144 | - 'ticketIn' => 'Ticket.TKT_ID', |
|
145 | - 'ticketIdIn' => 'Ticket.TKT_ID', |
|
146 | - 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
147 | - 'priceType' => 'Price_Type.PRT_ID', |
|
148 | - 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
149 | - 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
150 | - 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
151 | - 'priceBaseType' => 'Price_Type.PBT_ID', |
|
152 | - 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
153 | - ]; |
|
154 | - return $this->sanitizeWhereArgsForInputFields( |
|
155 | - $where_args, |
|
156 | - $arg_mapping, |
|
157 | - ['ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
158 | - ); |
|
159 | - } |
|
19 | + /** |
|
20 | + * @return EEM_Price |
|
21 | + * @throws EE_Error |
|
22 | + * @throws InvalidArgumentException |
|
23 | + * @throws InvalidDataTypeException |
|
24 | + * @throws InvalidInterfaceException |
|
25 | + */ |
|
26 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
27 | + public function get_query() |
|
28 | + { |
|
29 | + return EEM_Price::instance(); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Return an array of items from the query |
|
35 | + * |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
39 | + public function get_items() |
|
40 | + { |
|
41 | + $results = $this->query->get_col($this->query_args); |
|
42 | + |
|
43 | + return ! empty($results) ? $results : []; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Determine whether the Query should execute. If it's determined that the query should |
|
49 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
50 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
51 | + * Return false to prevent the query from executing. |
|
52 | + * |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
56 | + public function should_execute() |
|
57 | + { |
|
58 | + if ($this->should_execute === false) { |
|
59 | + return false; |
|
60 | + } |
|
61 | + |
|
62 | + return $this->should_execute; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
68 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
69 | + * handle batch resolution of the posts. |
|
70 | + * |
|
71 | + * @return array |
|
72 | + * @throws EE_Error |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws ReflectionException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + */ |
|
78 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | + public function get_query_args() |
|
80 | + { |
|
81 | + $where_params = []; |
|
82 | + $query_args = []; |
|
83 | + |
|
84 | + $query_args['limit'] = $this->getLimit(); |
|
85 | + |
|
86 | + // Avoid multiple entries by join. |
|
87 | + $query_args['group_by'] = 'PRC_ID'; |
|
88 | + |
|
89 | + /** |
|
90 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
91 | + */ |
|
92 | + $input_fields = []; |
|
93 | + if (! empty($this->args['where'])) { |
|
94 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
95 | + |
|
96 | + // Use the proper operator. |
|
97 | + if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
98 | + $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
99 | + } |
|
100 | + if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
101 | + $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
102 | + } |
|
103 | + if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
104 | + $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
110 | + */ |
|
111 | + if ($this->source instanceof EE_Ticket) { |
|
112 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Merge the input_fields with the default query_args |
|
117 | + */ |
|
118 | + if (! empty($input_fields)) { |
|
119 | + $where_params = array_merge($where_params, $input_fields); |
|
120 | + } |
|
121 | + |
|
122 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
123 | + |
|
124 | + $query_args[] = $where_params; |
|
125 | + |
|
126 | + /** |
|
127 | + * Return the $query_args |
|
128 | + */ |
|
129 | + return $query_args; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
135 | + * friendly keys. |
|
136 | + * |
|
137 | + * @param array $where_args |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + public function sanitizeInputFields(array $where_args) |
|
141 | + { |
|
142 | + $arg_mapping = [ |
|
143 | + 'ticket' => 'Ticket.TKT_ID', |
|
144 | + 'ticketIn' => 'Ticket.TKT_ID', |
|
145 | + 'ticketIdIn' => 'Ticket.TKT_ID', |
|
146 | + 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
147 | + 'priceType' => 'Price_Type.PRT_ID', |
|
148 | + 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
149 | + 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
150 | + 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
151 | + 'priceBaseType' => 'Price_Type.PBT_ID', |
|
152 | + 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
153 | + ]; |
|
154 | + return $this->sanitizeWhereArgsForInputFields( |
|
155 | + $where_args, |
|
156 | + $arg_mapping, |
|
157 | + ['ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
158 | + ); |
|
159 | + } |
|
160 | 160 | } |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
91 | 91 | */ |
92 | 92 | $input_fields = []; |
93 | - if (! empty($this->args['where'])) { |
|
93 | + if ( ! empty($this->args['where'])) { |
|
94 | 94 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
95 | 95 | |
96 | 96 | // Use the proper operator. |
97 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
97 | + if ( ! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
98 | 98 | $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
99 | 99 | } |
100 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
100 | + if ( ! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
101 | 101 | $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
102 | 102 | } |
103 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
103 | + if ( ! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
104 | 104 | $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
105 | 105 | } |
106 | 106 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | /** |
116 | 116 | * Merge the input_fields with the default query_args |
117 | 117 | */ |
118 | - if (! empty($input_fields)) { |
|
118 | + if ( ! empty($input_fields)) { |
|
119 | 119 | $where_params = array_merge($where_params, $input_fields); |
120 | 120 | } |
121 | 121 |
@@ -15,79 +15,79 @@ |
||
15 | 15 | class PriceTypeConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return EEM_Price_Type |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - */ |
|
25 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
26 | - public function get_query() |
|
27 | - { |
|
28 | - return EEM_Price_Type::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Price_Type |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + */ |
|
25 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
26 | + public function get_query() |
|
27 | + { |
|
28 | + return EEM_Price_Type::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Return an array of items from the query |
|
34 | - * |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
38 | - public function get_items() |
|
39 | - { |
|
40 | - $results = $this->query->get_col($this->query_args); |
|
32 | + /** |
|
33 | + * Return an array of items from the query |
|
34 | + * |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
38 | + public function get_items() |
|
39 | + { |
|
40 | + $results = $this->query->get_col($this->query_args); |
|
41 | 41 | |
42 | - return ! empty($results) ? $results : []; |
|
43 | - } |
|
42 | + return ! empty($results) ? $results : []; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Determine whether the Query should execute. If it's determined that the query should |
|
48 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
49 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
50 | - * Return false to prevent the query from executing. |
|
51 | - * |
|
52 | - * @return bool |
|
53 | - */ |
|
54 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
55 | - public function should_execute() |
|
56 | - { |
|
57 | - if ($this->should_execute === false) { |
|
58 | - return false; |
|
59 | - } |
|
46 | + /** |
|
47 | + * Determine whether the Query should execute. If it's determined that the query should |
|
48 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
49 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
50 | + * Return false to prevent the query from executing. |
|
51 | + * |
|
52 | + * @return bool |
|
53 | + */ |
|
54 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
55 | + public function should_execute() |
|
56 | + { |
|
57 | + if ($this->should_execute === false) { |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - return $this->should_execute; |
|
62 | - } |
|
61 | + return $this->should_execute; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
67 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
68 | - * handle batch resolution of the posts. |
|
69 | - * |
|
70 | - * @return array |
|
71 | - * @throws EE_Error |
|
72 | - * @throws InvalidArgumentException |
|
73 | - * @throws ReflectionException |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws InvalidInterfaceException |
|
76 | - */ |
|
77 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
78 | - public function get_query_args() |
|
79 | - { |
|
80 | - $where_params = []; |
|
81 | - $query_args = []; |
|
65 | + /** |
|
66 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
67 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
68 | + * handle batch resolution of the posts. |
|
69 | + * |
|
70 | + * @return array |
|
71 | + * @throws EE_Error |
|
72 | + * @throws InvalidArgumentException |
|
73 | + * @throws ReflectionException |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws InvalidInterfaceException |
|
76 | + */ |
|
77 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
78 | + public function get_query_args() |
|
79 | + { |
|
80 | + $where_params = []; |
|
81 | + $query_args = []; |
|
82 | 82 | |
83 | - $query_args['limit'] = $this->getLimit(); |
|
83 | + $query_args['limit'] = $this->getLimit(); |
|
84 | 84 | |
85 | - // Avoid multiple entries by join. |
|
86 | - $query_args['group_by'] = 'PRT_ID'; |
|
85 | + // Avoid multiple entries by join. |
|
86 | + $query_args['group_by'] = 'PRT_ID'; |
|
87 | 87 | |
88 | - /** |
|
89 | - * Return the $query_args |
|
90 | - */ |
|
91 | - return $query_args; |
|
92 | - } |
|
88 | + /** |
|
89 | + * Return the $query_args |
|
90 | + */ |
|
91 | + return $query_args; |
|
92 | + } |
|
93 | 93 | } |
@@ -18,51 +18,51 @@ |
||
18 | 18 | class RootQueryPriceTypesConnection extends AbstractRootQueryConnection |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EEM_Price_Type $model |
|
23 | - */ |
|
24 | - protected $model; |
|
21 | + /** |
|
22 | + * @var EEM_Price_Type $model |
|
23 | + */ |
|
24 | + protected $model; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * PriceTypeConnection constructor. |
|
29 | - * |
|
30 | - * @param EEM_Price_Type $model |
|
31 | - */ |
|
32 | - public function __construct(EEM_Price_Type $model) |
|
33 | - { |
|
34 | - $this->model = $model; |
|
35 | - } |
|
27 | + /** |
|
28 | + * PriceTypeConnection constructor. |
|
29 | + * |
|
30 | + * @param EEM_Price_Type $model |
|
31 | + */ |
|
32 | + public function __construct(EEM_Price_Type $model) |
|
33 | + { |
|
34 | + $this->model = $model; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return array |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function config() |
|
43 | - { |
|
44 | - return [ |
|
45 | - 'fromType' => 'RootQuery', |
|
46 | - 'toType' => 'PriceType', |
|
47 | - 'fromFieldName' => 'priceTypes', |
|
48 | - 'connectionTypeName' => 'RootQueryPriceTypesConnection', |
|
49 | - 'resolve' => [$this, 'resolveConnection'], |
|
50 | - 'resolveNode' => [$this, 'resolveNode'] |
|
51 | - ]; |
|
52 | - } |
|
38 | + /** |
|
39 | + * @return array |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function config() |
|
43 | + { |
|
44 | + return [ |
|
45 | + 'fromType' => 'RootQuery', |
|
46 | + 'toType' => 'PriceType', |
|
47 | + 'fromFieldName' => 'priceTypes', |
|
48 | + 'connectionTypeName' => 'RootQueryPriceTypesConnection', |
|
49 | + 'resolve' => [$this, 'resolveConnection'], |
|
50 | + 'resolveNode' => [$this, 'resolveNode'] |
|
51 | + ]; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @param $entity |
|
57 | - * @param $args |
|
58 | - * @param $context |
|
59 | - * @param $info |
|
60 | - * @return PriceTypeConnectionResolver |
|
61 | - * @throws Exception |
|
62 | - * @since $VID:$ |
|
63 | - */ |
|
64 | - public function getConnectionResolver($entity, $args, $context, $info) |
|
65 | - { |
|
66 | - return new PriceTypeConnectionResolver($entity, $args, $context, $info); |
|
67 | - } |
|
55 | + /** |
|
56 | + * @param $entity |
|
57 | + * @param $args |
|
58 | + * @param $context |
|
59 | + * @param $info |
|
60 | + * @return PriceTypeConnectionResolver |
|
61 | + * @throws Exception |
|
62 | + * @since $VID:$ |
|
63 | + */ |
|
64 | + public function getConnectionResolver($entity, $args, $context, $info) |
|
65 | + { |
|
66 | + return new PriceTypeConnectionResolver($entity, $args, $context, $info); |
|
67 | + } |
|
68 | 68 | } |
@@ -19,125 +19,125 @@ |
||
19 | 19 | class TicketPricesConnection implements ConnectionInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EEM_Price $model |
|
24 | - */ |
|
25 | - protected $model; |
|
22 | + /** |
|
23 | + * @var EEM_Price $model |
|
24 | + */ |
|
25 | + protected $model; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * TicketConnection constructor. |
|
30 | - * |
|
31 | - * @param EEM_Price $model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Price $model) |
|
34 | - { |
|
35 | - $this->model = $model; |
|
36 | - } |
|
28 | + /** |
|
29 | + * TicketConnection constructor. |
|
30 | + * |
|
31 | + * @param EEM_Price $model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Price $model) |
|
34 | + { |
|
35 | + $this->model = $model; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function config() |
|
44 | - { |
|
45 | - return [ |
|
46 | - 'fromType' => 'Ticket', |
|
47 | - 'toType' => 'Price', |
|
48 | - 'fromFieldName' => 'prices', |
|
49 | - 'connectionTypeName' => 'TicketPricesConnection', |
|
50 | - 'connectionArgs' => self::get_connection_args(), |
|
51 | - 'resolve' => [$this, 'resolveConnection'], |
|
52 | - 'resolveNode' => [$this, 'resolveNode'] |
|
53 | - ]; |
|
54 | - } |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function config() |
|
44 | + { |
|
45 | + return [ |
|
46 | + 'fromType' => 'Ticket', |
|
47 | + 'toType' => 'Price', |
|
48 | + 'fromFieldName' => 'prices', |
|
49 | + 'connectionTypeName' => 'TicketPricesConnection', |
|
50 | + 'connectionArgs' => self::get_connection_args(), |
|
51 | + 'resolve' => [$this, 'resolveConnection'], |
|
52 | + 'resolveNode' => [$this, 'resolveNode'] |
|
53 | + ]; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @param $entity |
|
59 | - * @param $args |
|
60 | - * @param $context |
|
61 | - * @param $info |
|
62 | - * @return array |
|
63 | - * @throws Exception |
|
64 | - * @since $VID:$ |
|
65 | - */ |
|
66 | - public function resolveConnection($entity, $args, $context, $info) |
|
67 | - { |
|
68 | - $resolver = new PriceConnectionResolver($entity, $args, $context, $info); |
|
69 | - return $resolver->get_connection(); |
|
70 | - } |
|
57 | + /** |
|
58 | + * @param $entity |
|
59 | + * @param $args |
|
60 | + * @param $context |
|
61 | + * @param $info |
|
62 | + * @return array |
|
63 | + * @throws Exception |
|
64 | + * @since $VID:$ |
|
65 | + */ |
|
66 | + public function resolveConnection($entity, $args, $context, $info) |
|
67 | + { |
|
68 | + $resolver = new PriceConnectionResolver($entity, $args, $context, $info); |
|
69 | + return $resolver->get_connection(); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * @param $id |
|
75 | - * @param $args |
|
76 | - * @param $context |
|
77 | - * @param $info |
|
78 | - * @return EE_Base_Class |
|
79 | - * @since $VID:$ |
|
80 | - */ |
|
81 | - public function resolveNode($id, $args, $context, $info) |
|
82 | - { |
|
83 | - return $this->model->get_one_by_ID($id); |
|
84 | - } |
|
73 | + /** |
|
74 | + * @param $id |
|
75 | + * @param $args |
|
76 | + * @param $context |
|
77 | + * @param $info |
|
78 | + * @return EE_Base_Class |
|
79 | + * @since $VID:$ |
|
80 | + */ |
|
81 | + public function resolveNode($id, $args, $context, $info) |
|
82 | + { |
|
83 | + return $this->model->get_one_by_ID($id); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Given an optional array of args, this returns the args to be used in the connection |
|
88 | - * |
|
89 | - * @access public |
|
90 | - * @param array $args The args to modify the defaults |
|
91 | - * |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
95 | - public static function get_connection_args($args = []) |
|
96 | - { |
|
97 | - return array_merge( |
|
98 | - [ |
|
99 | - 'ticket' => [ |
|
100 | - 'type' => 'ID', |
|
101 | - 'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'), |
|
102 | - ], |
|
103 | - 'ticketIn' => [ |
|
104 | - 'type' => ['list_of' => 'ID'], |
|
105 | - 'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'), |
|
106 | - ], |
|
107 | - 'ticketId' => [ |
|
108 | - 'type' => 'Int', |
|
109 | - 'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'), |
|
110 | - ], |
|
111 | - 'ticketIdIn' => [ |
|
112 | - 'type' => ['list_of' => 'Int'], |
|
113 | - 'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'), |
|
114 | - ], |
|
115 | - 'priceType' => [ |
|
116 | - 'type' => 'ID', |
|
117 | - 'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'), |
|
118 | - ], |
|
119 | - 'priceTypeIn' => [ |
|
120 | - 'type' => ['list_of' => 'ID'], |
|
121 | - 'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'), |
|
122 | - ], |
|
123 | - 'priceTypeId' => [ |
|
124 | - 'type' => 'Int', |
|
125 | - 'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'), |
|
126 | - ], |
|
127 | - 'priceTypeIdIn' => [ |
|
128 | - 'type' => ['list_of' => 'Int'], |
|
129 | - 'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'), |
|
130 | - ], |
|
131 | - 'priceBaseType' => [ |
|
132 | - 'type' => 'PriceBaseTypeEnum', |
|
133 | - 'description' => esc_html__('Price Base type.', 'event_espresso'), |
|
134 | - ], |
|
135 | - 'priceBaseTypeIn' => [ |
|
136 | - 'type' => ['list_of' => 'PriceBaseTypeEnum'], |
|
137 | - 'description' => esc_html__('Price Base types.', 'event_espresso'), |
|
138 | - ], |
|
139 | - ], |
|
140 | - $args |
|
141 | - ); |
|
142 | - } |
|
86 | + /** |
|
87 | + * Given an optional array of args, this returns the args to be used in the connection |
|
88 | + * |
|
89 | + * @access public |
|
90 | + * @param array $args The args to modify the defaults |
|
91 | + * |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
95 | + public static function get_connection_args($args = []) |
|
96 | + { |
|
97 | + return array_merge( |
|
98 | + [ |
|
99 | + 'ticket' => [ |
|
100 | + 'type' => 'ID', |
|
101 | + 'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'), |
|
102 | + ], |
|
103 | + 'ticketIn' => [ |
|
104 | + 'type' => ['list_of' => 'ID'], |
|
105 | + 'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'), |
|
106 | + ], |
|
107 | + 'ticketId' => [ |
|
108 | + 'type' => 'Int', |
|
109 | + 'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'), |
|
110 | + ], |
|
111 | + 'ticketIdIn' => [ |
|
112 | + 'type' => ['list_of' => 'Int'], |
|
113 | + 'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'), |
|
114 | + ], |
|
115 | + 'priceType' => [ |
|
116 | + 'type' => 'ID', |
|
117 | + 'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'), |
|
118 | + ], |
|
119 | + 'priceTypeIn' => [ |
|
120 | + 'type' => ['list_of' => 'ID'], |
|
121 | + 'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'), |
|
122 | + ], |
|
123 | + 'priceTypeId' => [ |
|
124 | + 'type' => 'Int', |
|
125 | + 'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'), |
|
126 | + ], |
|
127 | + 'priceTypeIdIn' => [ |
|
128 | + 'type' => ['list_of' => 'Int'], |
|
129 | + 'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'), |
|
130 | + ], |
|
131 | + 'priceBaseType' => [ |
|
132 | + 'type' => 'PriceBaseTypeEnum', |
|
133 | + 'description' => esc_html__('Price Base type.', 'event_espresso'), |
|
134 | + ], |
|
135 | + 'priceBaseTypeIn' => [ |
|
136 | + 'type' => ['list_of' => 'PriceBaseTypeEnum'], |
|
137 | + 'description' => esc_html__('Price Base types.', 'event_espresso'), |
|
138 | + ], |
|
139 | + ], |
|
140 | + $args |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | } |
@@ -18,52 +18,52 @@ |
||
18 | 18 | class RootQueryPricesConnection extends AbstractRootQueryConnection |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EEM_Price $model |
|
23 | - */ |
|
24 | - protected $model; |
|
21 | + /** |
|
22 | + * @var EEM_Price $model |
|
23 | + */ |
|
24 | + protected $model; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * PriceConnection constructor. |
|
29 | - * |
|
30 | - * @param EEM_Price $model |
|
31 | - */ |
|
32 | - public function __construct(EEM_Price $model) |
|
33 | - { |
|
34 | - $this->model = $model; |
|
35 | - } |
|
27 | + /** |
|
28 | + * PriceConnection constructor. |
|
29 | + * |
|
30 | + * @param EEM_Price $model |
|
31 | + */ |
|
32 | + public function __construct(EEM_Price $model) |
|
33 | + { |
|
34 | + $this->model = $model; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return array |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function config() |
|
43 | - { |
|
44 | - return [ |
|
45 | - 'fromType' => 'RootQuery', |
|
46 | - 'toType' => 'Price', |
|
47 | - 'fromFieldName' => 'prices', |
|
48 | - 'connectionTypeName' => 'RootQueryPricesConnection', |
|
49 | - 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
50 | - 'resolve' => [$this, 'resolveConnection'], |
|
51 | - 'resolveNode' => [$this, 'resolveNode'] |
|
52 | - ]; |
|
53 | - } |
|
38 | + /** |
|
39 | + * @return array |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function config() |
|
43 | + { |
|
44 | + return [ |
|
45 | + 'fromType' => 'RootQuery', |
|
46 | + 'toType' => 'Price', |
|
47 | + 'fromFieldName' => 'prices', |
|
48 | + 'connectionTypeName' => 'RootQueryPricesConnection', |
|
49 | + 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
50 | + 'resolve' => [$this, 'resolveConnection'], |
|
51 | + 'resolveNode' => [$this, 'resolveNode'] |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @param $entity |
|
58 | - * @param $args |
|
59 | - * @param $context |
|
60 | - * @param $info |
|
61 | - * @return PriceConnectionResolver |
|
62 | - * @throws Exception |
|
63 | - * @since $VID:$ |
|
64 | - */ |
|
65 | - public function getConnectionResolver($entity, $args, $context, $info) |
|
66 | - { |
|
67 | - return new PriceConnectionResolver($entity, $args, $context, $info); |
|
68 | - } |
|
56 | + /** |
|
57 | + * @param $entity |
|
58 | + * @param $args |
|
59 | + * @param $context |
|
60 | + * @param $info |
|
61 | + * @return PriceConnectionResolver |
|
62 | + * @throws Exception |
|
63 | + * @since $VID:$ |
|
64 | + */ |
|
65 | + public function getConnectionResolver($entity, $args, $context, $info) |
|
66 | + { |
|
67 | + return new PriceConnectionResolver($entity, $args, $context, $info); |
|
68 | + } |
|
69 | 69 | } |
@@ -22,88 +22,88 @@ |
||
22 | 22 | class PriceType extends TypeBase |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * PriceType constructor. |
|
27 | - * |
|
28 | - * @param EEM_Price_Type $price_type_model |
|
29 | - */ |
|
30 | - public function __construct(EEM_Price_Type $price_type_model) |
|
31 | - { |
|
32 | - $this->model = $price_type_model; |
|
33 | - $this->setName('PriceType'); |
|
34 | - $this->setDescription(__('A price type.', 'event_espresso')); |
|
35 | - $this->setIsCustomPostType(false); |
|
36 | - parent::__construct(); |
|
37 | - } |
|
25 | + /** |
|
26 | + * PriceType constructor. |
|
27 | + * |
|
28 | + * @param EEM_Price_Type $price_type_model |
|
29 | + */ |
|
30 | + public function __construct(EEM_Price_Type $price_type_model) |
|
31 | + { |
|
32 | + $this->model = $price_type_model; |
|
33 | + $this->setName('PriceType'); |
|
34 | + $this->setDescription(__('A price type.', 'event_espresso')); |
|
35 | + $this->setIsCustomPostType(false); |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @return GraphQLFieldInterface[] |
|
42 | - * @since $VID:$ |
|
43 | - */ |
|
44 | - public function getFields() |
|
45 | - { |
|
46 | - return [ |
|
47 | - new GraphQLField( |
|
48 | - 'id', |
|
49 | - ['non_null' => 'ID'], |
|
50 | - null, |
|
51 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
52 | - ), |
|
53 | - new GraphQLOutputField( |
|
54 | - lcfirst($this->name()) . 'Id', |
|
55 | - ['non_null' => 'Int'], |
|
56 | - 'ID', |
|
57 | - esc_html__('Price type ID', 'event_espresso') |
|
58 | - ), |
|
59 | - new GraphQLField( |
|
60 | - 'name', |
|
61 | - 'String', |
|
62 | - 'name', |
|
63 | - esc_html__('Price type Name', 'event_espresso') |
|
64 | - ), |
|
65 | - new GraphQLField( |
|
66 | - 'baseType', |
|
67 | - 'PriceBaseTypeEnum', |
|
68 | - 'base_type', |
|
69 | - esc_html__('Price Base type', 'event_espresso') |
|
70 | - ), |
|
71 | - new GraphQLField( |
|
72 | - 'order', |
|
73 | - 'Int', |
|
74 | - 'order', |
|
75 | - esc_html__('Order in which price should be applied.', 'event_espresso') |
|
76 | - ), |
|
77 | - new GraphQLField( |
|
78 | - 'isPercent', |
|
79 | - 'Boolean', |
|
80 | - 'is_percent', |
|
81 | - esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
82 | - ), |
|
83 | - new GraphQLOutputField( |
|
84 | - 'isDiscount', |
|
85 | - 'Boolean', |
|
86 | - 'is_discount', |
|
87 | - esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
88 | - ), |
|
89 | - new GraphQLField( |
|
90 | - 'isDeleted', |
|
91 | - 'Boolean', |
|
92 | - 'deleted', |
|
93 | - esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
94 | - ), |
|
95 | - new GraphQLOutputField( |
|
96 | - 'wpUser', |
|
97 | - 'User', |
|
98 | - null, |
|
99 | - esc_html__('Price Type Creator', 'event_espresso') |
|
100 | - ), |
|
101 | - new GraphQLInputField( |
|
102 | - 'wpUser', |
|
103 | - 'Int', |
|
104 | - null, |
|
105 | - esc_html__('Price Type Creator ID', 'event_espresso') |
|
106 | - ), |
|
107 | - ]; |
|
108 | - } |
|
40 | + /** |
|
41 | + * @return GraphQLFieldInterface[] |
|
42 | + * @since $VID:$ |
|
43 | + */ |
|
44 | + public function getFields() |
|
45 | + { |
|
46 | + return [ |
|
47 | + new GraphQLField( |
|
48 | + 'id', |
|
49 | + ['non_null' => 'ID'], |
|
50 | + null, |
|
51 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
52 | + ), |
|
53 | + new GraphQLOutputField( |
|
54 | + lcfirst($this->name()) . 'Id', |
|
55 | + ['non_null' => 'Int'], |
|
56 | + 'ID', |
|
57 | + esc_html__('Price type ID', 'event_espresso') |
|
58 | + ), |
|
59 | + new GraphQLField( |
|
60 | + 'name', |
|
61 | + 'String', |
|
62 | + 'name', |
|
63 | + esc_html__('Price type Name', 'event_espresso') |
|
64 | + ), |
|
65 | + new GraphQLField( |
|
66 | + 'baseType', |
|
67 | + 'PriceBaseTypeEnum', |
|
68 | + 'base_type', |
|
69 | + esc_html__('Price Base type', 'event_espresso') |
|
70 | + ), |
|
71 | + new GraphQLField( |
|
72 | + 'order', |
|
73 | + 'Int', |
|
74 | + 'order', |
|
75 | + esc_html__('Order in which price should be applied.', 'event_espresso') |
|
76 | + ), |
|
77 | + new GraphQLField( |
|
78 | + 'isPercent', |
|
79 | + 'Boolean', |
|
80 | + 'is_percent', |
|
81 | + esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
82 | + ), |
|
83 | + new GraphQLOutputField( |
|
84 | + 'isDiscount', |
|
85 | + 'Boolean', |
|
86 | + 'is_discount', |
|
87 | + esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
88 | + ), |
|
89 | + new GraphQLField( |
|
90 | + 'isDeleted', |
|
91 | + 'Boolean', |
|
92 | + 'deleted', |
|
93 | + esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
94 | + ), |
|
95 | + new GraphQLOutputField( |
|
96 | + 'wpUser', |
|
97 | + 'User', |
|
98 | + null, |
|
99 | + esc_html__('Price Type Creator', 'event_espresso') |
|
100 | + ), |
|
101 | + new GraphQLInputField( |
|
102 | + 'wpUser', |
|
103 | + 'Int', |
|
104 | + null, |
|
105 | + esc_html__('Price Type Creator ID', 'event_espresso') |
|
106 | + ), |
|
107 | + ]; |
|
108 | + } |
|
109 | 109 | } |
@@ -25,203 +25,203 @@ |
||
25 | 25 | class Price extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Price constructor. |
|
30 | - * |
|
31 | - * @param EEM_Price $price_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Price $price_model) |
|
34 | - { |
|
35 | - $this->model = $price_model; |
|
36 | - $this->setName('Price'); |
|
37 | - $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * Price constructor. |
|
30 | + * |
|
31 | + * @param EEM_Price $price_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Price $price_model) |
|
34 | + { |
|
35 | + $this->model = $price_model; |
|
36 | + $this->setName('Price'); |
|
37 | + $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - public function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'ID'], |
|
53 | - null, |
|
54 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLOutputField( |
|
57 | - lcfirst($this->name()) . 'Id', |
|
58 | - ['non_null' => 'Int'], |
|
59 | - 'ID', |
|
60 | - esc_html__('Price ID', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'name', |
|
64 | - 'String', |
|
65 | - 'name', |
|
66 | - esc_html__('Price Name', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'amount', |
|
70 | - 'Float', |
|
71 | - 'amount', |
|
72 | - esc_html__('Price Amount', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'desc', |
|
76 | - 'String', |
|
77 | - 'desc', |
|
78 | - esc_html__('Price description', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'overrides', |
|
82 | - 'Int', |
|
83 | - 'overrides', |
|
84 | - esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'order', |
|
88 | - 'Int', |
|
89 | - 'order', |
|
90 | - esc_html__('Order of Application of Price.', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLOutputField( |
|
93 | - 'parent', |
|
94 | - $this->name(), |
|
95 | - null, |
|
96 | - esc_html__('The parent price of the current price', 'event_espresso') |
|
97 | - ), |
|
98 | - new GraphQLInputField( |
|
99 | - 'parent', |
|
100 | - 'ID', |
|
101 | - null, |
|
102 | - esc_html__('The parent price ID', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLOutputField( |
|
105 | - 'priceType', |
|
106 | - 'PriceType', |
|
107 | - 'type_obj', |
|
108 | - esc_html__('The related price type object.', 'event_espresso') |
|
109 | - ), |
|
110 | - new GraphQLInputField( |
|
111 | - 'priceType', |
|
112 | - 'ID', |
|
113 | - null, |
|
114 | - esc_html__('The price type ID', 'event_espresso') |
|
115 | - ), |
|
116 | - new GraphQLOutputField( |
|
117 | - 'isDeleted', |
|
118 | - 'Boolean', |
|
119 | - 'deleted', |
|
120 | - esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
121 | - ), |
|
122 | - new GraphQLField( |
|
123 | - 'isDefault', |
|
124 | - 'Boolean', |
|
125 | - 'is_default', |
|
126 | - esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
127 | - ), |
|
128 | - new GraphQLOutputField( |
|
129 | - 'isPercent', |
|
130 | - 'Boolean', |
|
131 | - 'is_percent', |
|
132 | - esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
133 | - ), |
|
134 | - new GraphQLOutputField( |
|
135 | - 'isBasePrice', |
|
136 | - 'Boolean', |
|
137 | - 'is_base_price', |
|
138 | - esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
139 | - ), |
|
140 | - new GraphQLOutputField( |
|
141 | - 'isDiscount', |
|
142 | - 'Boolean', |
|
143 | - 'is_discount', |
|
144 | - esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
145 | - ), |
|
146 | - new GraphQLOutputField( |
|
147 | - 'wpUser', |
|
148 | - 'User', |
|
149 | - null, |
|
150 | - esc_html__('Price Creator', 'event_espresso') |
|
151 | - ), |
|
152 | - new GraphQLInputField( |
|
153 | - 'wpUser', |
|
154 | - 'Int', |
|
155 | - null, |
|
156 | - esc_html__('Price Creator ID', 'event_espresso') |
|
157 | - ), |
|
158 | - ]; |
|
159 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + public function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'ID'], |
|
53 | + null, |
|
54 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLOutputField( |
|
57 | + lcfirst($this->name()) . 'Id', |
|
58 | + ['non_null' => 'Int'], |
|
59 | + 'ID', |
|
60 | + esc_html__('Price ID', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'name', |
|
64 | + 'String', |
|
65 | + 'name', |
|
66 | + esc_html__('Price Name', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'amount', |
|
70 | + 'Float', |
|
71 | + 'amount', |
|
72 | + esc_html__('Price Amount', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'desc', |
|
76 | + 'String', |
|
77 | + 'desc', |
|
78 | + esc_html__('Price description', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'overrides', |
|
82 | + 'Int', |
|
83 | + 'overrides', |
|
84 | + esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'order', |
|
88 | + 'Int', |
|
89 | + 'order', |
|
90 | + esc_html__('Order of Application of Price.', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLOutputField( |
|
93 | + 'parent', |
|
94 | + $this->name(), |
|
95 | + null, |
|
96 | + esc_html__('The parent price of the current price', 'event_espresso') |
|
97 | + ), |
|
98 | + new GraphQLInputField( |
|
99 | + 'parent', |
|
100 | + 'ID', |
|
101 | + null, |
|
102 | + esc_html__('The parent price ID', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLOutputField( |
|
105 | + 'priceType', |
|
106 | + 'PriceType', |
|
107 | + 'type_obj', |
|
108 | + esc_html__('The related price type object.', 'event_espresso') |
|
109 | + ), |
|
110 | + new GraphQLInputField( |
|
111 | + 'priceType', |
|
112 | + 'ID', |
|
113 | + null, |
|
114 | + esc_html__('The price type ID', 'event_espresso') |
|
115 | + ), |
|
116 | + new GraphQLOutputField( |
|
117 | + 'isDeleted', |
|
118 | + 'Boolean', |
|
119 | + 'deleted', |
|
120 | + esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
121 | + ), |
|
122 | + new GraphQLField( |
|
123 | + 'isDefault', |
|
124 | + 'Boolean', |
|
125 | + 'is_default', |
|
126 | + esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
127 | + ), |
|
128 | + new GraphQLOutputField( |
|
129 | + 'isPercent', |
|
130 | + 'Boolean', |
|
131 | + 'is_percent', |
|
132 | + esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
133 | + ), |
|
134 | + new GraphQLOutputField( |
|
135 | + 'isBasePrice', |
|
136 | + 'Boolean', |
|
137 | + 'is_base_price', |
|
138 | + esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
139 | + ), |
|
140 | + new GraphQLOutputField( |
|
141 | + 'isDiscount', |
|
142 | + 'Boolean', |
|
143 | + 'is_discount', |
|
144 | + esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
145 | + ), |
|
146 | + new GraphQLOutputField( |
|
147 | + 'wpUser', |
|
148 | + 'User', |
|
149 | + null, |
|
150 | + esc_html__('Price Creator', 'event_espresso') |
|
151 | + ), |
|
152 | + new GraphQLInputField( |
|
153 | + 'wpUser', |
|
154 | + 'Int', |
|
155 | + null, |
|
156 | + esc_html__('Price Creator ID', 'event_espresso') |
|
157 | + ), |
|
158 | + ]; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * @param array $inputFields The mutation input fields. |
|
164 | - * @throws InvalidArgumentException |
|
165 | - * @throws ReflectionException |
|
166 | - * @since $VID:$ |
|
167 | - */ |
|
168 | - public function registerMutations(array $inputFields) |
|
169 | - { |
|
170 | - // Register mutation to update an entity. |
|
171 | - register_graphql_mutation( |
|
172 | - 'update' . $this->name(), |
|
173 | - [ |
|
174 | - 'inputFields' => $inputFields, |
|
175 | - 'outputFields' => [ |
|
176 | - lcfirst($this->name()) => [ |
|
177 | - 'type' => $this->name(), |
|
178 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
179 | - ], |
|
180 | - ], |
|
181 | - 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
182 | - ] |
|
183 | - ); |
|
184 | - // Register mutation to delete an entity. |
|
185 | - register_graphql_mutation( |
|
186 | - 'delete' . $this->name(), |
|
187 | - [ |
|
188 | - 'inputFields' => [ |
|
189 | - 'id' => $inputFields['id'], |
|
190 | - 'deletePermanently' => [ |
|
191 | - 'type' => 'Boolean', |
|
192 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
193 | - ], |
|
194 | - ], |
|
195 | - 'outputFields' => [ |
|
196 | - lcfirst($this->name()) => [ |
|
197 | - 'type' => $this->name(), |
|
198 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
199 | - 'resolve' => static function ($payload) { |
|
200 | - $deleted = (object) $payload['deleted']; |
|
162 | + /** |
|
163 | + * @param array $inputFields The mutation input fields. |
|
164 | + * @throws InvalidArgumentException |
|
165 | + * @throws ReflectionException |
|
166 | + * @since $VID:$ |
|
167 | + */ |
|
168 | + public function registerMutations(array $inputFields) |
|
169 | + { |
|
170 | + // Register mutation to update an entity. |
|
171 | + register_graphql_mutation( |
|
172 | + 'update' . $this->name(), |
|
173 | + [ |
|
174 | + 'inputFields' => $inputFields, |
|
175 | + 'outputFields' => [ |
|
176 | + lcfirst($this->name()) => [ |
|
177 | + 'type' => $this->name(), |
|
178 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
179 | + ], |
|
180 | + ], |
|
181 | + 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
182 | + ] |
|
183 | + ); |
|
184 | + // Register mutation to delete an entity. |
|
185 | + register_graphql_mutation( |
|
186 | + 'delete' . $this->name(), |
|
187 | + [ |
|
188 | + 'inputFields' => [ |
|
189 | + 'id' => $inputFields['id'], |
|
190 | + 'deletePermanently' => [ |
|
191 | + 'type' => 'Boolean', |
|
192 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
193 | + ], |
|
194 | + ], |
|
195 | + 'outputFields' => [ |
|
196 | + lcfirst($this->name()) => [ |
|
197 | + 'type' => $this->name(), |
|
198 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
199 | + 'resolve' => static function ($payload) { |
|
200 | + $deleted = (object) $payload['deleted']; |
|
201 | 201 | |
202 | - return ! empty($deleted) ? $deleted : null; |
|
203 | - }, |
|
204 | - ], |
|
205 | - ], |
|
206 | - 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
207 | - ] |
|
208 | - ); |
|
202 | + return ! empty($deleted) ? $deleted : null; |
|
203 | + }, |
|
204 | + ], |
|
205 | + ], |
|
206 | + 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
207 | + ] |
|
208 | + ); |
|
209 | 209 | |
210 | - // remove primary key from input. |
|
211 | - unset($inputFields['id']); |
|
212 | - // Register mutation to update an entity. |
|
213 | - register_graphql_mutation( |
|
214 | - 'create' . $this->name(), |
|
215 | - [ |
|
216 | - 'inputFields' => $inputFields, |
|
217 | - 'outputFields' => [ |
|
218 | - lcfirst($this->name()) => [ |
|
219 | - 'type' => $this->name(), |
|
220 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
221 | - ], |
|
222 | - ], |
|
223 | - 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
224 | - ] |
|
225 | - ); |
|
226 | - } |
|
210 | + // remove primary key from input. |
|
211 | + unset($inputFields['id']); |
|
212 | + // Register mutation to update an entity. |
|
213 | + register_graphql_mutation( |
|
214 | + 'create' . $this->name(), |
|
215 | + [ |
|
216 | + 'inputFields' => $inputFields, |
|
217 | + 'outputFields' => [ |
|
218 | + lcfirst($this->name()) => [ |
|
219 | + 'type' => $this->name(), |
|
220 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
221 | + ], |
|
222 | + ], |
|
223 | + 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
224 | + ] |
|
225 | + ); |
|
226 | + } |
|
227 | 227 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | esc_html__('The globally unique ID for the object.', 'event_espresso') |
55 | 55 | ), |
56 | 56 | new GraphQLOutputField( |
57 | - lcfirst($this->name()) . 'Id', |
|
57 | + lcfirst($this->name()).'Id', |
|
58 | 58 | ['non_null' => 'Int'], |
59 | 59 | 'ID', |
60 | 60 | esc_html__('Price ID', 'event_espresso') |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | // Register mutation to update an entity. |
171 | 171 | register_graphql_mutation( |
172 | - 'update' . $this->name(), |
|
172 | + 'update'.$this->name(), |
|
173 | 173 | [ |
174 | 174 | 'inputFields' => $inputFields, |
175 | 175 | 'outputFields' => [ |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | ); |
184 | 184 | // Register mutation to delete an entity. |
185 | 185 | register_graphql_mutation( |
186 | - 'delete' . $this->name(), |
|
186 | + 'delete'.$this->name(), |
|
187 | 187 | [ |
188 | 188 | 'inputFields' => [ |
189 | 189 | 'id' => $inputFields['id'], |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | lcfirst($this->name()) => [ |
197 | 197 | 'type' => $this->name(), |
198 | 198 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
199 | - 'resolve' => static function ($payload) { |
|
199 | + 'resolve' => static function($payload) { |
|
200 | 200 | $deleted = (object) $payload['deleted']; |
201 | 201 | |
202 | 202 | return ! empty($deleted) ? $deleted : null; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | unset($inputFields['id']); |
212 | 212 | // Register mutation to update an entity. |
213 | 213 | register_graphql_mutation( |
214 | - 'create' . $this->name(), |
|
214 | + 'create'.$this->name(), |
|
215 | 215 | [ |
216 | 216 | 'inputFields' => $inputFields, |
217 | 217 | 'outputFields' => [ |
@@ -25,283 +25,283 @@ |
||
25 | 25 | class Ticket extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Ticket constructor. |
|
30 | - * |
|
31 | - * @param EEM_Ticket $ticket_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Ticket $ticket_model) |
|
34 | - { |
|
35 | - $this->model = $ticket_model; |
|
36 | - $this->setName('Ticket'); |
|
37 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * Ticket constructor. |
|
30 | + * |
|
31 | + * @param EEM_Ticket $ticket_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Ticket $ticket_model) |
|
34 | + { |
|
35 | + $this->model = $ticket_model; |
|
36 | + $this->setName('Ticket'); |
|
37 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - public function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'ID'], |
|
53 | - null, |
|
54 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLOutputField( |
|
57 | - lcfirst($this->name()) . 'Id', |
|
58 | - ['non_null' => 'Int'], |
|
59 | - 'ID', |
|
60 | - esc_html__('Ticket ID', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'name', |
|
64 | - 'String', |
|
65 | - 'name', |
|
66 | - esc_html__('Ticket Name', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'description', |
|
70 | - 'String', |
|
71 | - 'description', |
|
72 | - esc_html__('Description of Ticket', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'startDate', |
|
76 | - 'String', |
|
77 | - 'start_date', |
|
78 | - esc_html__('Start time/date of Ticket', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'endDate', |
|
82 | - 'String', |
|
83 | - 'end_date', |
|
84 | - esc_html__('End time/date of Ticket', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'min', |
|
88 | - 'Int', |
|
89 | - 'min', |
|
90 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLField( |
|
93 | - 'max', |
|
94 | - 'Int', |
|
95 | - 'max', |
|
96 | - esc_html__( |
|
97 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
98 | - 'event_espresso' |
|
99 | - ), |
|
100 | - [$this, 'parseInfiniteValue'] |
|
101 | - ), |
|
102 | - new GraphQLField( |
|
103 | - 'price', |
|
104 | - 'Float', |
|
105 | - 'price', |
|
106 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLField( |
|
109 | - 'sold', |
|
110 | - 'Int', |
|
111 | - 'sold', |
|
112 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
113 | - ), |
|
114 | - new GraphQLField( |
|
115 | - 'quantity', |
|
116 | - 'Int', |
|
117 | - 'qty', |
|
118 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
119 | - [$this, 'parseInfiniteValue'] |
|
120 | - ), |
|
121 | - new GraphQLField( |
|
122 | - 'reserved', |
|
123 | - 'Int', |
|
124 | - 'reserved', |
|
125 | - esc_html__( |
|
126 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
127 | - 'event_espresso' |
|
128 | - ) |
|
129 | - ), |
|
130 | - new GraphQLField( |
|
131 | - 'uses', |
|
132 | - 'Int', |
|
133 | - 'uses', |
|
134 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
135 | - [$this, 'parseInfiniteValue'] |
|
136 | - ), |
|
137 | - new GraphQLField( |
|
138 | - 'isRequired', |
|
139 | - 'Boolean', |
|
140 | - 'required', |
|
141 | - esc_html__( |
|
142 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
143 | - 'event_espresso' |
|
144 | - ) |
|
145 | - ), |
|
146 | - new GraphQLField( |
|
147 | - 'isTaxable', |
|
148 | - 'Boolean', |
|
149 | - 'taxable', |
|
150 | - esc_html__( |
|
151 | - 'Flag indicating whether there is tax applied on this ticket', |
|
152 | - 'event_espresso' |
|
153 | - ) |
|
154 | - ), |
|
155 | - new GraphQLField( |
|
156 | - 'isDefault', |
|
157 | - 'Boolean', |
|
158 | - 'is_default', |
|
159 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
160 | - ), |
|
161 | - new GraphQLField( |
|
162 | - 'order', |
|
163 | - 'Int', |
|
164 | - 'order', |
|
165 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
166 | - ), |
|
167 | - new GraphQLField( |
|
168 | - 'row', |
|
169 | - 'Int', |
|
170 | - 'row', |
|
171 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
172 | - ), |
|
173 | - new GraphQLOutputField( |
|
174 | - 'wpUser', |
|
175 | - 'User', |
|
176 | - null, |
|
177 | - esc_html__('Ticket Creator', 'event_espresso') |
|
178 | - ), |
|
179 | - new GraphQLInputField( |
|
180 | - 'wpUser', |
|
181 | - 'Int', |
|
182 | - null, |
|
183 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
184 | - ), |
|
185 | - new GraphQLOutputField( |
|
186 | - 'parent', |
|
187 | - $this->name(), |
|
188 | - null, |
|
189 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
190 | - ), |
|
191 | - new GraphQLInputField( |
|
192 | - 'parent', |
|
193 | - 'ID', |
|
194 | - null, |
|
195 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
196 | - ), |
|
197 | - new GraphQLField( |
|
198 | - 'reverseCalculate', |
|
199 | - 'Boolean', |
|
200 | - 'reverse_calculate', |
|
201 | - esc_html__( |
|
202 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
203 | - 'event_espresso' |
|
204 | - ) |
|
205 | - ), |
|
206 | - new GraphQLField( |
|
207 | - 'isFree', |
|
208 | - 'Boolean', |
|
209 | - 'is_free', |
|
210 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
211 | - ), |
|
212 | - new GraphQLOutputField( |
|
213 | - 'event', |
|
214 | - 'Event', |
|
215 | - null, |
|
216 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
217 | - ), |
|
218 | - new GraphQLInputField( |
|
219 | - 'datetimes', |
|
220 | - ['list_of' => 'ID'], |
|
221 | - null, |
|
222 | - sprintf( |
|
223 | - '%1$s %2$s', |
|
224 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
225 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
226 | - ) |
|
227 | - ), |
|
228 | - new GraphQLInputField( |
|
229 | - 'prices', |
|
230 | - ['list_of' => 'ID'], |
|
231 | - null, |
|
232 | - sprintf( |
|
233 | - '%1$s %2$s', |
|
234 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
235 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
236 | - ) |
|
237 | - ), |
|
238 | - ]; |
|
239 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + public function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'ID'], |
|
53 | + null, |
|
54 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLOutputField( |
|
57 | + lcfirst($this->name()) . 'Id', |
|
58 | + ['non_null' => 'Int'], |
|
59 | + 'ID', |
|
60 | + esc_html__('Ticket ID', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'name', |
|
64 | + 'String', |
|
65 | + 'name', |
|
66 | + esc_html__('Ticket Name', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'description', |
|
70 | + 'String', |
|
71 | + 'description', |
|
72 | + esc_html__('Description of Ticket', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'startDate', |
|
76 | + 'String', |
|
77 | + 'start_date', |
|
78 | + esc_html__('Start time/date of Ticket', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'endDate', |
|
82 | + 'String', |
|
83 | + 'end_date', |
|
84 | + esc_html__('End time/date of Ticket', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'min', |
|
88 | + 'Int', |
|
89 | + 'min', |
|
90 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLField( |
|
93 | + 'max', |
|
94 | + 'Int', |
|
95 | + 'max', |
|
96 | + esc_html__( |
|
97 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
98 | + 'event_espresso' |
|
99 | + ), |
|
100 | + [$this, 'parseInfiniteValue'] |
|
101 | + ), |
|
102 | + new GraphQLField( |
|
103 | + 'price', |
|
104 | + 'Float', |
|
105 | + 'price', |
|
106 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLField( |
|
109 | + 'sold', |
|
110 | + 'Int', |
|
111 | + 'sold', |
|
112 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
113 | + ), |
|
114 | + new GraphQLField( |
|
115 | + 'quantity', |
|
116 | + 'Int', |
|
117 | + 'qty', |
|
118 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
119 | + [$this, 'parseInfiniteValue'] |
|
120 | + ), |
|
121 | + new GraphQLField( |
|
122 | + 'reserved', |
|
123 | + 'Int', |
|
124 | + 'reserved', |
|
125 | + esc_html__( |
|
126 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
127 | + 'event_espresso' |
|
128 | + ) |
|
129 | + ), |
|
130 | + new GraphQLField( |
|
131 | + 'uses', |
|
132 | + 'Int', |
|
133 | + 'uses', |
|
134 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
135 | + [$this, 'parseInfiniteValue'] |
|
136 | + ), |
|
137 | + new GraphQLField( |
|
138 | + 'isRequired', |
|
139 | + 'Boolean', |
|
140 | + 'required', |
|
141 | + esc_html__( |
|
142 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
143 | + 'event_espresso' |
|
144 | + ) |
|
145 | + ), |
|
146 | + new GraphQLField( |
|
147 | + 'isTaxable', |
|
148 | + 'Boolean', |
|
149 | + 'taxable', |
|
150 | + esc_html__( |
|
151 | + 'Flag indicating whether there is tax applied on this ticket', |
|
152 | + 'event_espresso' |
|
153 | + ) |
|
154 | + ), |
|
155 | + new GraphQLField( |
|
156 | + 'isDefault', |
|
157 | + 'Boolean', |
|
158 | + 'is_default', |
|
159 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
160 | + ), |
|
161 | + new GraphQLField( |
|
162 | + 'order', |
|
163 | + 'Int', |
|
164 | + 'order', |
|
165 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
166 | + ), |
|
167 | + new GraphQLField( |
|
168 | + 'row', |
|
169 | + 'Int', |
|
170 | + 'row', |
|
171 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
172 | + ), |
|
173 | + new GraphQLOutputField( |
|
174 | + 'wpUser', |
|
175 | + 'User', |
|
176 | + null, |
|
177 | + esc_html__('Ticket Creator', 'event_espresso') |
|
178 | + ), |
|
179 | + new GraphQLInputField( |
|
180 | + 'wpUser', |
|
181 | + 'Int', |
|
182 | + null, |
|
183 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
184 | + ), |
|
185 | + new GraphQLOutputField( |
|
186 | + 'parent', |
|
187 | + $this->name(), |
|
188 | + null, |
|
189 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
190 | + ), |
|
191 | + new GraphQLInputField( |
|
192 | + 'parent', |
|
193 | + 'ID', |
|
194 | + null, |
|
195 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
196 | + ), |
|
197 | + new GraphQLField( |
|
198 | + 'reverseCalculate', |
|
199 | + 'Boolean', |
|
200 | + 'reverse_calculate', |
|
201 | + esc_html__( |
|
202 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
203 | + 'event_espresso' |
|
204 | + ) |
|
205 | + ), |
|
206 | + new GraphQLField( |
|
207 | + 'isFree', |
|
208 | + 'Boolean', |
|
209 | + 'is_free', |
|
210 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
211 | + ), |
|
212 | + new GraphQLOutputField( |
|
213 | + 'event', |
|
214 | + 'Event', |
|
215 | + null, |
|
216 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
217 | + ), |
|
218 | + new GraphQLInputField( |
|
219 | + 'datetimes', |
|
220 | + ['list_of' => 'ID'], |
|
221 | + null, |
|
222 | + sprintf( |
|
223 | + '%1$s %2$s', |
|
224 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
225 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
226 | + ) |
|
227 | + ), |
|
228 | + new GraphQLInputField( |
|
229 | + 'prices', |
|
230 | + ['list_of' => 'ID'], |
|
231 | + null, |
|
232 | + sprintf( |
|
233 | + '%1$s %2$s', |
|
234 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
235 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
236 | + ) |
|
237 | + ), |
|
238 | + ]; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * @param array $inputFields The mutation input fields. |
|
244 | - * @throws InvalidArgumentException |
|
245 | - * @throws ReflectionException |
|
246 | - * @since $VID:$ |
|
247 | - */ |
|
248 | - public function registerMutations(array $inputFields) |
|
249 | - { |
|
250 | - // Register mutation to update an entity. |
|
251 | - register_graphql_mutation( |
|
252 | - 'update' . $this->name(), |
|
253 | - [ |
|
254 | - 'inputFields' => $inputFields, |
|
255 | - 'outputFields' => [ |
|
256 | - lcfirst($this->name()) => [ |
|
257 | - 'type' => $this->name(), |
|
258 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
259 | - ], |
|
260 | - ], |
|
261 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
262 | - ] |
|
263 | - ); |
|
264 | - // Register mutation to delete an entity. |
|
265 | - register_graphql_mutation( |
|
266 | - 'delete' . $this->name(), |
|
267 | - [ |
|
268 | - 'inputFields' => [ |
|
269 | - 'id' => $inputFields['id'], |
|
270 | - 'deletePermanently' => [ |
|
271 | - 'type' => 'Boolean', |
|
272 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
273 | - ], |
|
274 | - ], |
|
275 | - 'outputFields' => [ |
|
276 | - lcfirst($this->name()) => [ |
|
277 | - 'type' => $this->name(), |
|
278 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
279 | - 'resolve' => static function ($payload) { |
|
280 | - $deleted = (object) $payload['deleted']; |
|
242 | + /** |
|
243 | + * @param array $inputFields The mutation input fields. |
|
244 | + * @throws InvalidArgumentException |
|
245 | + * @throws ReflectionException |
|
246 | + * @since $VID:$ |
|
247 | + */ |
|
248 | + public function registerMutations(array $inputFields) |
|
249 | + { |
|
250 | + // Register mutation to update an entity. |
|
251 | + register_graphql_mutation( |
|
252 | + 'update' . $this->name(), |
|
253 | + [ |
|
254 | + 'inputFields' => $inputFields, |
|
255 | + 'outputFields' => [ |
|
256 | + lcfirst($this->name()) => [ |
|
257 | + 'type' => $this->name(), |
|
258 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
259 | + ], |
|
260 | + ], |
|
261 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
262 | + ] |
|
263 | + ); |
|
264 | + // Register mutation to delete an entity. |
|
265 | + register_graphql_mutation( |
|
266 | + 'delete' . $this->name(), |
|
267 | + [ |
|
268 | + 'inputFields' => [ |
|
269 | + 'id' => $inputFields['id'], |
|
270 | + 'deletePermanently' => [ |
|
271 | + 'type' => 'Boolean', |
|
272 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
273 | + ], |
|
274 | + ], |
|
275 | + 'outputFields' => [ |
|
276 | + lcfirst($this->name()) => [ |
|
277 | + 'type' => $this->name(), |
|
278 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
279 | + 'resolve' => static function ($payload) { |
|
280 | + $deleted = (object) $payload['deleted']; |
|
281 | 281 | |
282 | - return ! empty($deleted) ? $deleted : null; |
|
283 | - }, |
|
284 | - ], |
|
285 | - ], |
|
286 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
287 | - ] |
|
288 | - ); |
|
282 | + return ! empty($deleted) ? $deleted : null; |
|
283 | + }, |
|
284 | + ], |
|
285 | + ], |
|
286 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
287 | + ] |
|
288 | + ); |
|
289 | 289 | |
290 | - // remove primary key from input. |
|
291 | - unset($inputFields['id']); |
|
292 | - // Register mutation to update an entity. |
|
293 | - register_graphql_mutation( |
|
294 | - 'create' . $this->name(), |
|
295 | - [ |
|
296 | - 'inputFields' => $inputFields, |
|
297 | - 'outputFields' => [ |
|
298 | - lcfirst($this->name()) => [ |
|
299 | - 'type' => $this->name(), |
|
300 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
301 | - ], |
|
302 | - ], |
|
303 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
304 | - ] |
|
305 | - ); |
|
306 | - } |
|
290 | + // remove primary key from input. |
|
291 | + unset($inputFields['id']); |
|
292 | + // Register mutation to update an entity. |
|
293 | + register_graphql_mutation( |
|
294 | + 'create' . $this->name(), |
|
295 | + [ |
|
296 | + 'inputFields' => $inputFields, |
|
297 | + 'outputFields' => [ |
|
298 | + lcfirst($this->name()) => [ |
|
299 | + 'type' => $this->name(), |
|
300 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
301 | + ], |
|
302 | + ], |
|
303 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
304 | + ] |
|
305 | + ); |
|
306 | + } |
|
307 | 307 | } |
@@ -13,87 +13,87 @@ |
||
13 | 13 | class TicketMutation |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Maps the GraphQL input to a format that the model functions can use |
|
18 | - * |
|
19 | - * @param array $input Data coming from the GraphQL mutation query input |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public static function prepareFields(array $input) |
|
23 | - { |
|
24 | - |
|
25 | - $args = []; |
|
26 | - |
|
27 | - if (! empty($input['name'])) { |
|
28 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
29 | - } |
|
30 | - |
|
31 | - if (! empty($input['description'])) { |
|
32 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
33 | - } |
|
34 | - |
|
35 | - if (! empty($input['price'])) { |
|
36 | - $args['TKT_price'] = floatval($input['price']); |
|
37 | - } |
|
38 | - |
|
39 | - if (! empty($input['datetimes'])) { |
|
40 | - $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
41 | - } |
|
42 | - |
|
43 | - if (! empty($input['prices'])) { |
|
44 | - $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
|
45 | - } |
|
46 | - |
|
47 | - // Likewise the other fields... |
|
48 | - |
|
49 | - return $args; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Sets the related datetimes for the given ticket. |
|
54 | - * |
|
55 | - * @param EE_Ticket $entity The Ticket instance. |
|
56 | - * @param array $datetimes Array of datetime IDs to relate. |
|
57 | - */ |
|
58 | - public static function setRelatedDatetimes($entity, array $datetimes) |
|
59 | - { |
|
60 | - $relationName = 'Datetime'; |
|
61 | - // Remove all the existing related datetimes |
|
62 | - |
|
63 | - $entity->_remove_relations($relationName); |
|
64 | - // @todo replace loop with single query |
|
65 | - foreach ($datetimes as $ID) { |
|
66 | - $parts = Relay::fromGlobalId($ID); |
|
67 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
68 | - $entity->_add_relation_to( |
|
69 | - $parts['id'], |
|
70 | - $relationName |
|
71 | - ); |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Sets the related prices for the given ticket. |
|
78 | - * |
|
79 | - * @param EE_Ticket $entity The Ticket instance. |
|
80 | - * @param array $prices Array of entity IDs to relate. |
|
81 | - */ |
|
82 | - public static function setRelatedPrices($entity, array $prices) |
|
83 | - { |
|
84 | - $relationName = 'Price'; |
|
85 | - // Remove all the existing related entities |
|
86 | - $entity->_remove_relations($relationName); |
|
87 | - |
|
88 | - // @todo replace loop with single query |
|
89 | - foreach ($prices as $ID) { |
|
90 | - $parts = Relay::fromGlobalId($ID); |
|
91 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
92 | - $entity->_add_relation_to( |
|
93 | - $parts['id'], |
|
94 | - $relationName |
|
95 | - ); |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
16 | + /** |
|
17 | + * Maps the GraphQL input to a format that the model functions can use |
|
18 | + * |
|
19 | + * @param array $input Data coming from the GraphQL mutation query input |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public static function prepareFields(array $input) |
|
23 | + { |
|
24 | + |
|
25 | + $args = []; |
|
26 | + |
|
27 | + if (! empty($input['name'])) { |
|
28 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
29 | + } |
|
30 | + |
|
31 | + if (! empty($input['description'])) { |
|
32 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
33 | + } |
|
34 | + |
|
35 | + if (! empty($input['price'])) { |
|
36 | + $args['TKT_price'] = floatval($input['price']); |
|
37 | + } |
|
38 | + |
|
39 | + if (! empty($input['datetimes'])) { |
|
40 | + $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
41 | + } |
|
42 | + |
|
43 | + if (! empty($input['prices'])) { |
|
44 | + $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
|
45 | + } |
|
46 | + |
|
47 | + // Likewise the other fields... |
|
48 | + |
|
49 | + return $args; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Sets the related datetimes for the given ticket. |
|
54 | + * |
|
55 | + * @param EE_Ticket $entity The Ticket instance. |
|
56 | + * @param array $datetimes Array of datetime IDs to relate. |
|
57 | + */ |
|
58 | + public static function setRelatedDatetimes($entity, array $datetimes) |
|
59 | + { |
|
60 | + $relationName = 'Datetime'; |
|
61 | + // Remove all the existing related datetimes |
|
62 | + |
|
63 | + $entity->_remove_relations($relationName); |
|
64 | + // @todo replace loop with single query |
|
65 | + foreach ($datetimes as $ID) { |
|
66 | + $parts = Relay::fromGlobalId($ID); |
|
67 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
68 | + $entity->_add_relation_to( |
|
69 | + $parts['id'], |
|
70 | + $relationName |
|
71 | + ); |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Sets the related prices for the given ticket. |
|
78 | + * |
|
79 | + * @param EE_Ticket $entity The Ticket instance. |
|
80 | + * @param array $prices Array of entity IDs to relate. |
|
81 | + */ |
|
82 | + public static function setRelatedPrices($entity, array $prices) |
|
83 | + { |
|
84 | + $relationName = 'Price'; |
|
85 | + // Remove all the existing related entities |
|
86 | + $entity->_remove_relations($relationName); |
|
87 | + |
|
88 | + // @todo replace loop with single query |
|
89 | + foreach ($prices as $ID) { |
|
90 | + $parts = Relay::fromGlobalId($ID); |
|
91 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
92 | + $entity->_add_relation_to( |
|
93 | + $parts['id'], |
|
94 | + $relationName |
|
95 | + ); |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | 99 | } |
@@ -24,23 +24,23 @@ discard block |
||
24 | 24 | |
25 | 25 | $args = []; |
26 | 26 | |
27 | - if (! empty($input['name'])) { |
|
27 | + if ( ! empty($input['name'])) { |
|
28 | 28 | $args['TKT_name'] = sanitize_text_field($input['name']); |
29 | 29 | } |
30 | 30 | |
31 | - if (! empty($input['description'])) { |
|
31 | + if ( ! empty($input['description'])) { |
|
32 | 32 | $args['TKT_description'] = sanitize_text_field($input['description']); |
33 | 33 | } |
34 | 34 | |
35 | - if (! empty($input['price'])) { |
|
35 | + if ( ! empty($input['price'])) { |
|
36 | 36 | $args['TKT_price'] = floatval($input['price']); |
37 | 37 | } |
38 | 38 | |
39 | - if (! empty($input['datetimes'])) { |
|
39 | + if ( ! empty($input['datetimes'])) { |
|
40 | 40 | $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
41 | 41 | } |
42 | 42 | |
43 | - if (! empty($input['prices'])) { |
|
43 | + if ( ! empty($input['prices'])) { |
|
44 | 44 | $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
45 | 45 | } |
46 | 46 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | // @todo replace loop with single query |
65 | 65 | foreach ($datetimes as $ID) { |
66 | 66 | $parts = Relay::fromGlobalId($ID); |
67 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
67 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
68 | 68 | $entity->_add_relation_to( |
69 | 69 | $parts['id'], |
70 | 70 | $relationName |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | // @todo replace loop with single query |
89 | 89 | foreach ($prices as $ID) { |
90 | 90 | $parts = Relay::fromGlobalId($ID); |
91 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
91 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
92 | 92 | $entity->_add_relation_to( |
93 | 93 | $parts['id'], |
94 | 94 | $relationName |